Announcements
Dear All,
I have been working on workflow development for Dynamics 365 F&O. In Purchase order workflow while configuring there are 2 Approval elements available(Same as AX 2012 R3). One is workflow Approve purchase order and other one is Approve purchase order, editable. My query is about the development of the 2nd one which says Editable (highlighted below as well). As per my testing if I associate this element while configuration, system allows the Approvers to edit the purchase order and then take the approval action afterwards.
I am developing a custom workflow and want to have the same feature mentioned above with my custom workflow. I have tried to look into some of the system default code but couldn’t managed to get some deeper and identify the area where certain validation are being applied for Approval editable element at the time of purchase order workflow execution.
Let me clear once again that I have looked into the related classes for Purchase order workflow like event handler and document classes. If anyone has worked on this then kindly share Ideas which classes should I look into for such validation of editable on the basis of Workflow approval element and replicate the same for my workflow.
Up.
Would this work to enable editing of Procurement category in a Purchase requisition or Purchase order workflow? I have a client with this requirement. Thanks!
Thanks everyone for responses. It is resolved. I was able to dig down and find the method written on table PurchTable in AOT
Through this we can achieve the requirement by calling it on Form Activate event or whatever the event you want the fields to be disabled or enabled. Basically this returns true if Current user has been assigned with approval work item in workflow. and False in case not.
/// <summary>
/// Indicates whether the user can modify the record when an active workflow is running.
/// </summary>
/// <returns>
/// true if the user has rights to modify the record; false.
/// </returns>
public boolean editableInWorkflow()
{
WorkflowElementTable workflowElementTable;
WorkflowWorkItemTable workflowWorkItemTable; select firstonly ElementId from workflowWorkItemTable
where workflowWorkItemTable.RefTableId == this.TableId
&& workflowWorkItemTable.RefRecId == this.RecId
&& workflowWorkItemTable.UserId == curUserId()
&& workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending
join ElementId, ElementType from workflowElementTable
where workflowElementTable.ElementId == workflowWorkItemTable.ElementId
&& (workflowElementTable.ElementName == workFlowApprovalStr(PurchTableApprovalEdit)
|| workflowElementTable.ElementName == workFlowTaskStr(PurchTableTaskEdit));
return workflowWorkItemTable.RecId != 0;
}
Editable Approvals just allow approvers to edit the selected record (that they are approving) You can implement same by following steps:
public boolean editAllowed() { WorkflowElementTable workflowElementTable; WorkflowWorkItemTable workflowWorkItemTable; select * from workflowWorkItemTable where workflowWorkItemTable.RefRecId == this.RecId && workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending && workflowWorkItemTable.UserId == curUserId() && workflowWorkItemTable.CompanyId == this.DataAreaId; select * from workflowElementTable where workflowElementTable.ElementId == workflowWorkItemTable.ElementId; return workflowElementTable.ElementName == workflowApprovalStr(CaseDetailBaseApprovalEdit) || this.CaseWFStatus == CaseWFStatus::Draft; } }
public int active() { FormRun formRun = this.formRun() as FormRun; FormDataSource ds = formRun.dataSource(); CaseDetailBase table = ds.cursor(); boolean allowEdit = table.editAllowed(); ds.allowEdit(allowEdit); if(allowEdit) { formRun.design().viewEditMode(ViewEditMode::Edit); } else { formRun.design().viewEditMode(ViewEditMode::View); } return next active(); }
HI Muhammad,
I haven't looked into this myself, but also have a look at possible coding on the table, form and form/table related classes (PurchTableType, PurchTableForm)
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,186 Super User 2024 Season 2
Martin Dráb 227,996 Super User 2024 Season 2
nmaenpaa 101,148