Workflow
hierarchy assignment usually provides limited options to select the start of
the given hierarchy. Most common options to select for the
start of hierarchy are Workflow owner, Workflow originator, Personnel number,
User etc. E.g. the workflow is assigned to the managerial hierarchy of the workflow
originator.
Problem
To add hierarchy token using custom workflow hierarchy
provider, so that we have option to select the start of hierarchy other than
those already provided by the default provider.
Solution
Execution
Problem
Solution
To achieve above requirement, follow the steps below to
create custom workflow hierarchy provider and add the token using it.
Step#1 In order
to add a custom workflow hierarchy provider, refer the blog How to add custom workflow hierarchy assignment provider
Step#2 Add new
EDT which extends HcmWorkerRecId
Step#3 Assign the
EDT to the table field, which you want to be the starting point for workflow
managerial hierarchy.
Step#4 Implement
the method getSupportedType of custom
workflow hierarchy provider class to add your data type i.e.
MY_SupervisorWorkerRecId
public Set getSupportedDataType()
{
Set supportedDataTypes =
helper.getSupportedDataType();
if(!supportedDataTypes)
{
supportedDataTypes = new Set(Types::String);
}
//Add the required
data types
supportedDataTypes.add(extendedTypeStr(MY_SupervisorWorkerRecId));
return supportedDataTypes;
}
Step#5 Implement
the method convertToNodeDataType of
custom workflow hierarchy provider class to
fetch the worker’s personnel number using the field value from the record
(workflow document).
public anytype convertToNodeDataType(extendedDataTypeName _dataType,
anytype _value,
WorkflowContext _workflowContext)
{
HcmPersonnelNumberId personnelNumberId;
if(_dataType == extendedTypeStr(MY_SupervisorWorkerRecId))
{
personnelNumberId = HcmWorker::find(_value).PersonnelNumber;
}
else
{
personnelNumberId = helper.convertToNodeDataType(_dataType,
_value, _workflowContext);
}
return personnelNumberId;
}
Step#6 Build the relevant model.
Execution
Setup workflow using custom hierarchy token for supervisor
A task to submit workflow by Admin. We need the workflow
approval from line manager of the supervisor here i.e. Aaliyah.
Workflow is assigned to the line manager of Aaliya i.e. Adam
Carter, as specified in the workflow designer
Hello Mehwish,
ReplyDeleteI have to do same thing for my leave journal workflow. I have added new field in my table and its showing in Hierarchy selection Start from > New field. When I run workflow process for submitting leave request then I am getting an error below.
Stopped (error): SysWorkflowQueue-resume
X++ Exception: Worker ID not set or record not found for %1, %2.
Verify that the extended data type matches, and that the worker exists.
at SysWorkflowHierarchyProvider-resolve
SysWorkflowHierarchyProvider-resolveHierarchy
Note : I did not add any custom workflow provider and I am using standard workflow provider. I am using Dynamics 365 F&O - Update 15.
Did you solve this issue? Thank you!
DeleteHi,
ReplyDeleteCan you specify what EDT is assigned to your table field which you have selected from Start from selection?
Check if that EDT is resolved/handled to get the employee's personnel number in the class method WorkflowHierarchyProviderHelper.convertToNodeDataType()
Also make sure that table field (the one selected in Start from selection) value is not null/0 in the table record on the the workflow is operating.