通过实例 ID 获取工作流详细信息

Get Workflow details by instance id

我有工作流历史 oob 列表,它将工作流历史数据存储在工作流历史父实例 ID、工作流模板 ID、工作流关联 ID、listid.... 字段中。

我想通过工作流实例 ID 检索工作流详细信息,例如工作流名称,该 ID 按照我在上面的 SharePoint Online OOB 列表中提到的方式存储。如何实现?

提前致谢

工作流实例服务通用 api。

<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.workflowservices.js"></script>
    <script type="text/javascript">
        function RetrieveWorkflowInstances() {
            var context = SP.ClientContext.get_current();
            var web = context.get_web();
            var workflowServicesManager = new SP.WorkflowServices.WorkflowServicesManager(context, web);
            //var workflowDeploymentService = workflowServicesManager.getWorkflowDeploymentService();
            var workflowInstanceService = workflowServicesManager.getWorkflowInstanceService();

            //6a899d24-4813-4920-9e61-cdaa2cfe1b3a
            var specificInstance = workflowInstanceService.getInstance("6a899d24-4813-4920-9e61-cdaa2cfe1b3a");
            context.load(specificInstance);
            context.executeQueryAsync(function (sender, args) {
                console.log(specificInstance);
            }, function (sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
                });

            // get all instances
            var workflowInstances = workflowInstanceService.enumerateInstancesForListItem("7B96090E-FDAD-4075-B24A-21686AE255B4", 1);
            context.load(workflowInstances);
            context.executeQueryAsync(function (sender, args) {
                // enumerateDefinition returns ClientCollection object
                var definitionsEnum = workflowInstances.getEnumerator();
                // Going through the definitions
                while (definitionsEnum.moveNext()) {
                    var def = definitionsEnum.get_current();
                    // Displaying information about this definition - DisplayName and Id
                    console.log("id: " + def.get_id() + " Status: " + def.get_status() + " Stage: " + def.get_userStatus());
                }

            }, function (sender, args) {
                alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
            });
        }
    </script>
    <input id="Button1" onclick="RetrieveWorkflowInstances()" type="button" value="button" />

workflow instance properties