Play around with D365FO workflow .. Some code samples to
1. Current workflow User a by code
public WorkflowUser currentWFUser(Common _common)
{
WorkflowTrackingStatusTable workflowTrackingStatusTable;
WorkflowTrackingTable workflowTrackingTable;
select firstonly RecId from workflowTrackingStatusTable
join User from workflowTrackingTable
order by WorkflowTrackingTable.CreatedDateTime desc
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingStatusTable.ContextRecId == _common.RecId
&& workflowTrackingStatusTable.ContextTableId == _common.TableId
&& workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem;
return workflowTrackingTable.User;
}
2. Approve a workflow by code
public void autoApproveWF(Common _common, str _user)
{
WorkflowWorkItemTable WorkflowWorkItemTable;
select WorkflowWorkItemTable
where workflowWorkItemTable.Type == WorkflowWorkItemType::WorkItem
&& workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending
&& WorkflowWorkItemTable.RefTableId== _common.TableId
&& WorkflowWorkItemTable.RefRecId == _common.RecId;
WorkflowWorkItemActionManager::dispatchWorkItemAction(
WorkflowWorkItemTable,
"Auto Approve by system",
_user,
WorkflowWorkItemActionType::Complete,
menuitemDisplayStr(PurchReqTable));
}
3, Display approver name
display WorkflowApprovalName Displayapprovername()
{
WorkflowTrackingStatusTable workflowTrackingStatusTable;
WorkflowTrackingTable WorkflowTrackingTable;
WorkflowApprovalName approvername;
select firstonly workflowtrackingstatustable
join workflowtrackingtable
where workflowtrackingstatustable.ContextRecId == this.recid
&& workflowtrackingtable.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowtrackingtable.TrackingType == workflowtrackingtype::Approval
&& workflowtrackingtable.WorkflowTrackingStatusTable == workflowtrackingstatustable .recid;
{
approvername = workflowtrackingtable.User;
}
return approvername;
}
4. Get last approver name for PO by PurchID
select firstFast _PURCHTABLE where _PURCHTABLE.PurchId == purchTable.PurchId ;
select firstFast _WorkflowTrackingStatusTable
order by _WorkflowTrackingStatusTable.RecId desc
where _WorkflowTrackingStatusTable.ContextRecId == _PURCHTABLE.RecId && _WorkflowTrackingStatusTable.ContextCompanyId == curext()
&& _WorkflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed ;
select _WorkflowTrackingTable
order by _WorkflowTrackingTable.createdDateTime desc
where _WorkflowTrackingTable.WorkflowTrackingStatusTable == _WorkflowTrackingStatusTable.RecId
&& _WorkflowTrackingTable.TrackingType == 4 ;
Published on:
Learn moreRelated posts
Power Automate: Fixing the ‘ChildFlowNeverPublished’ Error
While trying to enable one of the cloud flows from a managed solution I had installed, I encountered the following error: “{“erro...
Power Automate – Information regarding the end of support for Document Automation Toolkit
On November 15, 2025, the Document Automation Toolkitfeature in Power Automate reached of support. How does this affect me? Makers will no lon...
AI Agent Security: Applying Presume Breach and Least Privilege in Microsoft Copilot Studio & Power Automate
AI-backed tools are powerful and easy to develop. Give an agent access and clear instructions, and in many cases, it can just do the job. Howe...
Power Automate – Enable process mining integration in process map
We are announcing the ability to enable process mining integration in process map in Power Automate. This feature will reach general availabil...
How to Automate Image Descriptions with AI Builder in Power Automate
In today’s fast-paced digital world, automating repetitive tasks not only saves time but also significantly improves productivity. Microsoft n...
How to Identify and Update Power Automate HTTP Request Trigger Flows Before November 2025
Few weeks back, while working on one of our Power Automate flows, we noticed a banner warning on the HTTP Request trigger step. Microsoft has ...
Power Automate – HTTP and Teams webhook trigger flows are moving to new URLs
As of August 2025, Power Automate flows and Agent flows (Copilot Studio) with HTTP triggers or Teams Webhook triggers that have logic.azure.co...
How to Automate Document Signing with DocuSign in Power Automate
Introduction In an earlier Inogic post, “Streamlining E-Signatures in Multi-Step Forms with Power Pages and DocuSign Integration”, Our previou...
Power Automate Retry and Error Handling Patterns for Reliable Power Pages Integrations
When Power Pages integrates with Power Automate, reliability becomes key. Portal users expect instant responses — whether submitting a form, u...
Handling Large Files in Power Automate
Power Automate can handle large files, but how large? SharePoint Online supports files up to 250 GB, which sounds generous until you try movin...