Workflow Started from a Form: How to Associate a Newly Created Asset as the Task's Related Resource?
Summary: Matheus Anitelli is facing a challenge with associating an asset as a Related Resource in a workflow initiated from a form. The redesigned process creates an Initiative asset and relationships with Business Terms, but user tasks do not display the Initiative as a Related Resource, causing identification issues. Matheus Anitelli has attempted several methods to pass the Initiative ID but without success. George Cheung suggests that the Related Resource is determined at workflow instantiation and recommends starting a new workflow instance using the workflowInstanceApi. Anil Vemula asks about transferring variables to a new workflow, and George Cheung provides a code example for creating assets, starting a workflow on them, and passing variables.
Hi everyone,
I'm facing a workflow design challenge and would appreciate any guidance from those who have implemented similar patterns.
Background
Originally, our Data Definition workflow was started directly from a Business Term asset page. In that scenario, each user task displayed the asset as the Related Resource in the user's Inbox and task details. Users could immediately understand which asset they were working on and navigate to it easily.
We have recently redesigned the process.
The new flow is:
User launches a workflow from a start form (not from an asset page).
The workflow creates a new Initiative asset.
The workflow creates relationships between the Initiative and multiple Business Terms.
A Call Activity launches a child workflow (Data Definition Process).
Users receive tasks within the child workflow.
The Problem
Because the workflow is initiated from a form rather than from an asset page, the resulting user tasks do not display a Related Resource.
The Initiative asset is successfully created and its ID is available throughout the process. I can retrieve the asset and its metadata in Script Tasks without any issue.
However, the user tasks still do not show the Initiative as the Related Resource, making it difficult for users to identify which Initiative a task belongs to.
What I've Already Tried
Passing the Initiative ID through Call Activity input mappings.
Passing an
itemvariable through the Call Activity.Recreating the Initiative asset context in the child workflow using:
Recreating the Initiative asset context in the child workflow using:
Storing the Initiative asset ID and name as workflow variables.
The child workflow receives these values correctly, but the Related Resource remains empty.
My Question
Is it possible to associate a workflow instance or user task with an asset after the workflow has already started, so that the asset appears as the Related Resource in the Inbox?
More specifically:
Can a workflow started from a global form dynamically set a Related Resource later in the process?
Is there a specific workflow variable (such as
item,resourceId, etc.) that controls this behavior?Or is the Related Resource only determined at workflow instantiation time when the workflow is launched directly from an asset page?
Any recommendations, best practices, or examples would be greatly appreciated.
Thanks in advance!
Anil Vemula
·4 days agoHi @George Cheung
How do I send the all the variables from this workflow to new workflow?
George Cheung
·4 days ago · Edited//example code for creating asset, starting secondary workflow on new asset, and pass in variables import com.collibra.dgc.core.api.dto.instance.asset.AddAssetRequest import com.collibra.dgc.core.api.dto.workflow.StartWorkflowInstancesRequest import com.collibra.dgc.core.api.model.workflow.WorkflowBusinessItemType def newAssetId = assetApi.addAsset(AddAssetRequest.builder().name(assetName).domainId(domainId).typePublicId("BusinessAsset").build()).getId() execution.setVariable('outputCreatedTermId', newAssetId.toString()) // finding the workflow definition with the hard coded workflowProcessId of 'customApprovalProcess' def workflowDefId = workflowDefinitionApi.getWorkflowDefinitionByProcessId("customApprovalProcess").getId() def formProperties = [: ] formProperties.variableName = "Variable Value" formProperties.anotherVariableName = "Another Variable Value" workflowInstanceApi.startWorkflowInstances(StartWorkflowInstancesRequest.builder() .workflowDefinitionId(workflowDefId) .formProperties(formProperties) .businessItemIds([newAssetId]) .businessItemType(WorkflowBusinessItemType.ASSET) .build())George Cheung
·3 weeks agoThe Related Resource only determined at workflow instantiation time when the workflow is launched.
A workflow instance can only run on a single related resource. To 'change' the resource, you must start a new workflow instance.
If you launch a global workflow (without a related resource) to create an asset, assigning tasks to that new asset requires a separate workflow definition. You can use the workflowInstanceApi.startWorkflowInstances method to start a new workflow instance on that new asset. The called workflow will trigger immediately, allowing the main workflow to continue its remaining tasks without waiting for it to finish.