User selection feature in "Request Change" workflow action X++
H guys,
Another blog that will be useful for those who are using workflow functionality regularly.
Background:
"Request Change" is the most commonly used workflow action. User selection feature was available in "Request Change" workflow action prior to D365 FO 10.0.8 (PU32) versions but this feature has been depreciated by Microsoft from D365 FO 10.0.8 (PU32) versions for security issue and it is not available in later versions.
As a result of this change by Microsoft, system automatically assigns workflow to the Initiator or Submitter of the workflow which fails the workflow process in those cases where in there are multiple departments involves in the same workflow approval cycle.
Requirement:
Let's take an example of Purchase requisition workflow. Purchase requisition is being raised by IT personnel from IT department for purchasing one Laptop and submits the workflow that involves Procurement and Finance department approvals. If workflow is assigned to the Finance department after Procurement department approval and Finance department wants some amendments in Purchase requisition to be done by Procurement department. For these changes, Finance performs the "Request Change" workflow action on which they weren't able to select the Procurement user and workflow is assigned to IT user who is not aware of the changes in the Purchase requisition then it will break the whole workflow approval cycle and ultimately it will disturb business operations. I came across similar kind of requirement where user selection feature was required as this feature was being used so often by users and process owners were not at all accepting this solution that's why i had to make changes in the core functionality of workflow in order to fulfill the business requirements.
Solution:
Below is the code snippet of the solution that is working absolutely fine. I hope this will be helpful for you if you have the same requirements as I had.
Create two new Extension classes
Below class will make user selection feature visible in Request Change dialog form
[ExtensionOf(formStr(WorkflowWorkItemActionDialog))]
final class WorkflowWorkItemActionDialog_Extension
{
public void run()
{
next run();
switch (workflowWorkItemActionDialog.parmWorkItemActionType())
{
case WorkflowWorkItemActionType::RequestChange:
groupUser.visible(true);
}
}
}
Below class will override the request change process by replacing workflow submitted user with the user selected in the user drop down in Request change dialog form
[ExtensionOf(classStr(WorkflowWorkItemActionManager))]
final class WorkflowWorkItemActionManager_Extension
{
public static void dispatchWorkItemAction( WorkflowWorkItemTable _workItem,
WorkflowComment _comment,
WorkflowUser _toUser,
WorkflowWorkItemActionType _workItemActionType,
menuItemName _menuItemName,
Name _queueName)
{
#Workflow
SysWorkflowTable workflowTable;
SysDictWorkflowElement dictElement;
if (_workItemActionType == WorkflowWorkItemActionType::RequestChange)
{
_workItemActionType = WorkflowWorkItemActionType::Deny;
}
next dispatchWorkItemAction(_workItem,
_comment,
_toUser,
_workItemActionType,
_menuItemName,
_queueName);
}
}

Like
Report
*This post is locked for comments