如何使用Microsoft Flow获取任务的资源名称-Project Online连接器

时间:2019-08-14 09:20:58

标签: sharepoint sharepoint-online power-automate microsoft-project-vba project-online

我在sharepoint中使用项目在线Web应用程序。而且我正在尝试使用流程连接器-在线项目中创建新任务时,项目在线连接器向资源名称发送电子邮件通知。

但是我无法找到已创建并分配资源的每个任务的资源名称。

我尝试使用创建新的任务触发器,但是在该触发器的动态内容中未同时列出任务名称和资源名称,原因是我无法识别为哪个任务分配了哪个资源。

我尝试使用创建新资源触发器,但这仅在创建新资源时执行,而不是在将新资源分配给任务时执行。所以我的流程不停地运转。

触发器-创建新任务时 根站点URL-https:/nameofwebsite.sharepoint.com/nameofprojectonlineapp

操作-发送电子邮件通知(V3)(预览)

To- ResourceName / ResourceEmailID“除非我使用资源触发器,否则此选项不可用” 主题-退回任务项目名称 电子邮件正文-您必须在“返回的任务任务开始日期”和“返回的任务任务完成日期”之内完成此任务

我想使用Microsoft Flow中的连接器查找每个任务的资源名称

1 个答案:

答案 0 :(得分:1)

这是我提取资源名称的方法...

首先列出任务

然后您将每个输出应用于“返回的任务”

enter image description here

然后在“应用于每个对象”中

  • 您将HTTP请求发送到SharePoint(我将ProjectID存储为变量)

enter image description here

  • 现在您使用HTTP请求中的正文作为内容来解析JSON

enter image description here

这里是架构

{
    "type": "object",
    "properties": {
        "d": {
            "type": "object",
            "properties": {
                "results": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "__metadata": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "uri": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string"
                                    }
                                }
                            },
                            "CustomFields": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Owner": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Parent": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Resource": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "Task": {
                                "type": "object",
                                "properties": {
                                    "__deferred": {
                                        "type": "object",
                                        "properties": {
                                            "uri": {
                                                "type": "string"
                                            }
                                        }
                                    }
                                }
                            },
                            "ActualCostWorkPerformed": {
                                "type": "integer"
                            },
                            "ActualOvertimeCost": {
                                "type": "integer"
                            },
                            "BaselineCost": {
                                "type": "integer"
                            },
                            "BaselineCostPerUse": {
                                "type": "integer"
                            },
                            "BaselineFinish": {
                                "type": "string"
                            },
                            "BaselineStart": {
                                "type": "string"
                            },
                            "BaselineWork": {},
                            "BaselineWorkMilliseconds": {
                                "type": "integer"
                            },
                            "BaselineWorkTimeSpan": {
                                "type": "string"
                            },
                            "BudgetedCostWorkPerformed": {
                                "type": "integer"
                            },
                            "BudgetedCostWorkScheduled": {
                                "type": "integer"
                            },
                            "CostVariance": {
                                "type": "integer"
                            },
                            "CostVarianceAtCompletion": {
                                "type": "integer"
                            },
                            "Created": {
                                "type": "string"
                            },
                            "CurrentCostVariance": {
                                "type": "integer"
                            },
                            "Finish": {
                                "type": "string"
                            },
                            "FinishVariance": {
                                "type": "string"
                            },
                            "FinishVarianceMilliseconds": {
                                "type": "integer"
                            },
                            "FinishVarianceTimeSpan": {
                                "type": "string"
                            },
                            "Id": {
                                "type": "string"
                            },
                            "IsConfirmed": {
                                "type": "boolean"
                            },
                            "IsOverAllocated": {
                                "type": "boolean"
                            },
                            "IsPublished": {
                                "type": "boolean"
                            },
                            "IsResponsePending": {
                                "type": "boolean"
                            },
                            "IsUpdateNeeded": {
                                "type": "boolean"
                            },
                            "LevelingDelay": {
                                "type": "string"
                            },
                            "LevelingDelayMilliseconds": {
                                "type": "integer"
                            },
                            "LevelingDelayTimeSpan": {
                                "type": "string"
                            },
                            "Modified": {
                                "type": "string"
                            },
                            "Notes": {},
                            "OvertimeCost": {
                                "type": "integer"
                            },
                            "RemainingCost": {
                                "type": "integer"
                            },
                            "RemainingOvertimeCost": {
                                "type": "integer"
                            },
                            "Resume": {
                                "type": "string"
                            },
                            "ScheduleCostVariance": {
                                "type": "integer"
                            },
                            "Start": {
                                "type": "string"
                            },
                            "StartVariance": {
                                "type": "string"
                            },
                            "StartVarianceMilliseconds": {
                                "type": "integer"
                            },
                            "StartVarianceTimeSpan": {
                                "type": "string"
                            },
                            "Stop": {
                                "type": "string"
                            },
                            "WorkContourType": {
                                "type": "integer"
                            },
                            "WorkVariance": {
                                "type": "string"
                            },
                            "WorkVarianceMilliseconds": {
                                "type": "integer"
                            },
                            "WorkVarianceTimeSpan": {
                                "type": "string"
                            },
                            "ActualCost": {
                                "type": "integer"
                            },
                            "ActualFinish": {
                                "type": "string"
                            },
                            "ActualOvertimeWork": {
                                "type": "string"
                            },
                            "ActualOvertimeWorkMilliseconds": {
                                "type": "integer"
                            },
                            "ActualOvertimeWorkTimeSpan": {
                                "type": "string"
                            },
                            "ActualStart": {
                                "type": "string"
                            },
                            "ActualWork": {
                                "type": "string"
                            },
                            "ActualWorkMilliseconds": {
                                "type": "integer"
                            },
                            "ActualWorkTimeSpan": {
                                "type": "string"
                            },
                            "BudgetedCost": {
                                "type": "integer"
                            },
                            "BudgetedWork": {
                                "type": "string"
                            },
                            "BudgetedWorkMilliseconds": {
                                "type": "integer"
                            },
                            "BudgetedWorkTimeSpan": {
                                "type": "string"
                            },
                            "Cost": {
                                "type": "integer"
                            },
                            "CostRateTable": {
                                "type": "integer"
                            },
                            "DefaultBookingType": {
                                "type": "integer"
                            },
                            "Delay": {
                                "type": "string"
                            },
                            "DelayMilliseconds": {
                                "type": "integer"
                            },
                            "DelayTimeSpan": {
                                "type": "string"
                            },
                            "IsLockedByManager": {
                                "type": "boolean"
                            },
                            "IsWorkResource": {
                                "type": "boolean"
                            },
                            "OvertimeWork": {
                                "type": "string"
                            },
                            "OvertimeWorkMilliseconds": {
                                "type": "integer"
                            },
                            "OvertimeWorkTimeSpan": {
                                "type": "string"
                            },
                            "PercentWorkComplete": {
                                "type": "integer"
                            },
                            "RegularWork": {
                                "type": "string"
                            },
                            "RegularWorkMilliseconds": {
                                "type": "integer"
                            },
                            "RegularWorkTimeSpan": {
                                "type": "string"
                            },
                            "RemainingOvertimeWork": {
                                "type": "string"
                            },
                            "RemainingOvertimeWorkMilliseconds": {
                                "type": "integer"
                            },
                            "RemainingOvertimeWorkTimeSpan": {
                                "type": "string"
                            },
                            "RemainingWork": {
                                "type": "string"
                            },
                            "RemainingWorkMilliseconds": {
                                "type": "integer"
                            },
                            "RemainingWorkTimeSpan": {
                                "type": "string"
                            },
                            "ResourceCapacity": {
                                "type": [
                                    "integer",
                                    "number"
                                ]
                            },
                            "Work": {
                                "type": "string"
                            },
                            "WorkMilliseconds": {
                                "type": "integer"
                            },
                            "WorkTimeSpan": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "__metadata",
                            "CustomFields",
                            "Owner",
                            "Parent",
                            "Resource",
                            "Task",
                            "ActualCostWorkPerformed",
                            "ActualOvertimeCost",
                            "BaselineCost",
                            "BaselineCostPerUse",
                            "BaselineFinish",
                            "BaselineStart",
                            "BaselineWork",
                            "BaselineWorkMilliseconds",
                            "BaselineWorkTimeSpan",
                            "BudgetedCostWorkPerformed",
                            "BudgetedCostWorkScheduled",
                            "CostVariance",
                            "CostVarianceAtCompletion",
                            "Created",
                            "CurrentCostVariance",
                            "Finish",
                            "FinishVariance",
                            "FinishVarianceMilliseconds",
                            "FinishVarianceTimeSpan",
                            "Id",
                            "IsConfirmed",
                            "IsOverAllocated",
                            "IsPublished",
                            "IsResponsePending",
                            "IsUpdateNeeded",
                            "LevelingDelay",
                            "LevelingDelayMilliseconds",
                            "LevelingDelayTimeSpan",
                            "Modified",
                            "Notes",
                            "OvertimeCost",
                            "RemainingCost",
                            "RemainingOvertimeCost",
                            "Resume",
                            "ScheduleCostVariance",
                            "Start",
                            "StartVariance",
                            "StartVarianceMilliseconds",
                            "StartVarianceTimeSpan",
                            "Stop",
                            "WorkContourType",
                            "WorkVariance",
                            "WorkVarianceMilliseconds",
                            "WorkVarianceTimeSpan",
                            "ActualCost",
                            "ActualFinish",
                            "ActualOvertimeWork",
                            "ActualOvertimeWorkMilliseconds",
                            "ActualOvertimeWorkTimeSpan",
                            "ActualStart",
                            "ActualWork",
                            "ActualWorkMilliseconds",
                            "ActualWorkTimeSpan",
                            "BudgetedCost",
                            "BudgetedWork",
                            "BudgetedWorkMilliseconds",
                            "BudgetedWorkTimeSpan",
                            "Cost",
                            "CostRateTable",
                            "DefaultBookingType",
                            "Delay",
                            "DelayMilliseconds",
                            "DelayTimeSpan",
                            "IsLockedByManager",
                            "IsWorkResource",
                            "OvertimeWork",
                            "OvertimeWorkMilliseconds",
                            "OvertimeWorkTimeSpan",
                            "PercentWorkComplete",
                            "RegularWork",
                            "RegularWorkMilliseconds",
                            "RegularWorkTimeSpan",
                            "RemainingOvertimeWork",
                            "RemainingOvertimeWorkMilliseconds",
                            "RemainingOvertimeWorkTimeSpan",
                            "RemainingWork",
                            "RemainingWorkMilliseconds",
                            "RemainingWorkTimeSpan",
                            "ResourceCapacity",
                            "Work",
                            "WorkMilliseconds",
                            "WorkTimeSpan"
                        ]
                    }
                }
            }
        }
    }
}

然后您组成解析的JSON的结果

@{body('Parse_JSON')?['d']?['results']}

enter image description here

现在将AssignmentId设置为...

@{outputs('Compose_2')?[0]?['Id']}

enter image description here

现在创建条件。.如果AssignmentId不等于空白,则...

enter image description here

SetAssignedTo值为

@{outputs('Compose')?['d']?['Name']}

我确信他们是这样做的一种更干净的方法,但至少我可以提取资源名称(又名AssignedTo)