Announcements
Hi,
This is my first time creating a custom workflow.
I was referring to this article to create custom workflow for SalesTable https://devmusings.blog/2018/03/18/custom-workflows-in-microsoft-dynamics-365-for-operations/
I added canSubmitToWorkflow() & updateWorkflowStatus() method on SalesTable using CoC.
Submit menu item points to correct submit manager class.
In SalesTable form, I already modified Workflow Data Source, Workflow Enabled & Workflow Type properties.
However, the workflow button is not appearing when I open the form.
What else do I need to verify?
Thank you.
Apparently, there's standard code that show/hide the button in SalesTable form:
////// Check if workflow action button will be displayed. /// /// /// Workflow type. /// /// /// Return true if any line needs to submit and not submitted. /// public boolean canSubmitToWorkflow(str _workflowType = '') { boolean ret; MCRSalesLine mcrSalesLineLocal; SalesLine salesLineLocal; if (mcrSalesLine) { // if current line is not submitted or approved if (mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::NotSubmitted || mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Approved || mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::None) { // and if any non submit line is need to submit for approval select firstonly RecId from mcrSalesLineLocal join RecId from salesLineLocal where mcrSalesLineLocal.SalesLine == salesLineLocal.RecId && salesLineLocal.SalesId == salesTable.SalesId && mcrSalesLineLocal.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::NotSubmitted; if (mcrSalesLineLocal) { ret = true; } } } // hide workflow action button even if the line is rejected and the line's status is None and no not submitted lines element.design().controlName("WorkflowActionBarButtonGroup").visible(ret || mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::None); return ret; }
Here's my updated extension. This able to show the workflow button as expected:
public boolean canSubmitToWorkflow(str workflowtype) { boolean canSubmit = false; canSubmit = next canSubmitToWorkflow(workflowtype); canSubmit = SalesTable.canSubmitToWorkflow(); this.design().controlName("WorkflowActionBarButtonGroup").visible(this.design().workflowEnabled()); return canSubmit; }
Regards.
Hi Junaid,
Workflow methods on SalesTable table extension:
[ExtensionOf(tablestr(SalesTable))] final class SalesTable_WorkflowTest_Extension { public boolean canSubmitToWorkflow(str workflowType) { boolean canSubmit = false; canSubmit = next canSubmitToWorkflow(workflowType); if (this.RecId && this.WorkflowState == VersioningDocumentState::Draft) { canSubmit = true; } return canSubmit; } public static void updateWorkflowStatus(RecId _documentRecId, VersioningDocumentState _status) { ttsbegin; SalesTable salesTable; update_recordset salesTable setting WorkflowState = _status where salesTable.RecId == _documentRecId; ttscommit; } }
Workflow type properties:
SalesTableListPage form extension properties:
Workflow button is displayed and working fine in SalesTableListPage:
SalesTable form extension properties:
Although Workflow Enabled set to Yes, Workflow Type is specified, workflow button is not showing in SalesTable form:
What am I missing? Thank you.
Hi HAIRUL HAZRI,
Yes we don't have Activate change management option for Sales Order workflow, it's only at Procurement and sourcing part.
Can you please share some screen prints of an error to better understanding.
New update.
For SalesTableListPage , everything is OK now. I can submit the workflow, approve, reject, delegate, request to change, cancel
successfully.
However, the workflow button still not appears in SalesTable form. I still cant find what I did wrong or where else to verify.
Is it the Document Menu Item in Workflow Type? SalesTable display menu item should be the correct one, am I right?
Not exactly everything is OK.
SalesTableListPage form displays the workflow button, but when I try to submit, I get "Function WorkflowWorkItemActionDialog.run has been incorrectly called." error.
SalesTable form not displaying the workflow button.
I already added canSubmitToWorkflow to SalesTable table using CoC as mentioned above. Do I need to add in other than SalesTable table?
So, for SalesTableListPage , everything is OK. not for SalesTable?
Have you also added canSubmitToWorkflow to SalesTable?
Active change management in Procurement & Sourcing parameters is enabled.
But supposedly this is only applicable for Purchase order workflow right? I don't see Active change management in Sales and marketing parameters, Accounts receivable parameters.
And another thing, seems like the workflow button is displayed in SalesTableListPage form, but not in SalesTable form.
Even though both forms have enable the same workflow. Any idea why this happened?
Hi Sir,
Check this : community.dynamics.com/.../workflow-button-is-not-displaying-on-a-form
I mean AOS services.
Hi Blue Wang,
The canSubmitToWorkflow method is not triggered. What did I miss in this case?
By restart services, you mean which services?
Hi HAIRUL HAZRI ,
Have you debugged canSubmitToWorkflow method? and pass parameter?
If everything is ok, please restart services.
André Arnaud de Cal...
294,099
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator