Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

workflow in sales order

(0) ShareShare
ReportReport
Posted on by 3,945

hi all , i am doing the workflow for sales order.
 where i will write the code so that after clicking the "approve" button of workflow the button like sales confirmation , Invoice , packing list , packing slip should get enabled , and before that these button should be disabled.
Please suggest where i will write the code , i have written in SaleTables:active (active method at datasource level of SalesTable form) , but its not working
Thanks 

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: workflow in sales order

    Hi Sohaib

        Its working good but In the same scenario i would like to disable all the buttons like picking, packing, Invoice....

    How could i achieve it?

  • Gautam Profile Picture
    3,945 on at
    RE: workflow in sales order

    hi Sohaib ,

    Thanks a lot , its working fine

    but one small doubt , how you came to know that this method canConfirmationBeUpdated() is invoking to control these buttons.

  • Verified answer
    Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: workflow in sales order

    before "return ok;" write your code

    no need to write .enabled (true) or false

    simply write like as under

    if(salesTable.WFApprovalField != WFApprovalFieldBaseEnum::Approved)

       {

           ok = false;

       }

  • Gautam Profile Picture
    3,945 on at
    RE: workflow in sales order

    ya Halland , AX is re-enabling those buttons.

  • Gautam Profile Picture
    3,945 on at
    RE: workflow in sales order

    hi Sohaib

    I got your point , i have looked into the SalesTableType  class and canConfirmationBeUpdated  method is there .

    where i will add my code/condition , can you please tell me

    boolean  canConfirmationBeUpdated(DocumentStatus _documentStatus = DocumentStatus::Confirmation)

    {

       boolean  ok = true;

       if (_documentStatus == DocumentStatus::Confirmation)

       {

           ok = this.mayConfirmationBeUpdated();

       }

       if (ok)

       {

           if (salesTable.SalesStatus != SalesStatus::Backorder ||

               !(salesTable.existInterCompanySales() || salesTable.existDirectDelivery()))

           {

               ok = this.canPackingslipBeUpdated(_documentStatus);

           }

           else

           {

               if (!salesTable.canCustomerBeUpdated(_documentStatus))

               {

                   ok = false;

               }

           }

       }

       if (ok)

       {

           ok = salesTable.checkCreditCard();

       }

       return ok;

    }

    Thanks

  • Jonathan  Halland Profile Picture
    11,306 on at
    RE: workflow in sales order

    Hi Gautam

    From your description now, it doesn't seem like this is a workflow problem itself, but as Sohaib suggests, your code is conflicting with base code, so you're disabling buttons that AX simply re-enables.

    Sohaib's suggestions should help you in resolving this.

  • Gautam Profile Picture
    3,945 on at
    RE: workflow in sales order

    hi faisal

    my workFlowStatus field is ConfirmationApprovalStatus in SalesTable

    have a look to this code

    if(salesTable.ConfirmationApprovalStatus != SalesConfirmationApprovalStatus::Approved)

       {

           buttonUpdateConfirmation.enabled(false);

           buttonProformaConfirmation.enabled(false);

           buttonUpdatePickingList.enabled(false);

           buttonUpdatePickingListRegistrate.enabled(false);

           buttonUpdatePackingSlip.enabled(false);

           buttonProformaPackingSlip.enabled(false);

           buttonUpdateInvoice.enabled(false);

           buttonProformaInvoice.enabled(false);

           info("ok");

       }

       else

       {

           buttonUpdateConfirmation.enabled(true);

           buttonProformaConfirmation.enabled(true);

           buttonUpdatePickingList.enabled(true);

           buttonUpdatePickingListRegistrate.enabled(true);

           buttonUpdatePackingSlip.enabled(true);

           buttonProformaPackingSlip.enabled(true);

           buttonUpdateInvoice.enabled(true);

           buttonProformaInvoice.enabled(true);

           info("Not ok");

       }

       SalesTable_ds.refreshEx();

    i have done the same which you told but still not working .

    Thanks

  • Suggested answer
    Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: workflow in sales order

    it should be in a different way because now with list pages, we cannot directly address/point to Buttons. i.e. writing code on active method of form datasource is not very best approach now. Also, as a workflow may be active on two forms at same time i.e. SalesTable and SalesTableListPage

    In addition, there is already code written by Microsoft where they are controlling buttons as of standard AX i.e. "Don't allow sales order to be confirmed until it has valid sales line(s)"

    Better if we write our code at same place where already standard code is there, for two reasons

    1) all code to control buttons enable/ disable buttons should be at one location

    2) it should work independently/same either on SalesTable or SalesTableListPage

    The code to enable disable these button should be written in calss SalesTableType

    for confirmation write code in canConfirmationBeUpdated (method) of SalesTableType (class)

    write code before return ok;

  • Gautam Profile Picture
    3,945 on at
    RE: workflow in sales order

    Hi Halland

    i have written the code in active method of SalesTable(at datasource ) to disable the menuitem button.

    whenever i open the form SalesTable ,then which all the menu item button i have disabled from the active method is disabled here but the problem is that when we are adding item in salesline these menuitem get enabled automatically .

    Then i have written the same code in active method of salesline(datasource) as well but facing same issue .

    Thanks

  • Jonathan  Halland Profile Picture
    11,306 on at
    RE: workflow in sales order

    Hi Gautam. Please review my notes above as to the procedures to follow to accomplish what you want. You need to make two sets of code changes ultimately to do what you want.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans