web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Custom Workflow Button Not Appear in Form

(0) ShareShare
ReportReport
Posted on by 1,214

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.

I have the same question (0)
  • Blue Wang Profile Picture
    on at

    Hi HAIRUL HAZRI ,

    Have you debugged canSubmitToWorkflow method? and pass parameter?

    If everything is ok, please restart services.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Blue Wang,

    The canSubmitToWorkflow method is not triggered. What did I miss in this case?

    By restart services, you mean which services?

  • Blue Wang Profile Picture
    on at

    Hi Sir,

    Check this : community.dynamics.com/.../workflow-button-is-not-displaying-on-a-form

    I mean AOS services.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    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?

  • Blue Wang Profile Picture
    on at

    So, for SalesTableListPage , everything is OK. not for SalesTable?

    Have you also added canSubmitToWorkflow  to SalesTable?

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    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?

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    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?

  • Suggested answer
    Junaid Idrees Profile Picture
    on at

    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.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    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:

    salestabletemplate.png

    SalesTableListPage form extension properties:

    salestablelistpage-property.png

    Workflow button is displayed and working fine in SalesTableListPage:

    salestablelistpage.png

    SalesTable form extension properties:

    salestable-property.png

    Although Workflow Enabled set to Yes, Workflow Type is specified, workflow button is not showing in SalesTable form:

    salestable.png

    What am I missing? Thank you.

  • Suggested answer
    HAIRUL HAZRI Profile Picture
    1,214 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans