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 :
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

I have the same question (0)
  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    Your workflow would have generated **AporovalEventHandler class, in this class you will have completed method. You can write your code here.

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi Gautam.

    There are two things you will need to do.

    1. Place code in your ApprovalEventHandler class to set a status variable to "approved", you can't control the buttons from here though.

    2. In the active method of your SalesOrder datasource you will need to check if status is "approved" and then active the buttons from there.

    Note the event handler may take a minute or two before it executes after the approve is clicked. So this won't be immediate. But this is the way all the workflows work

  • Gautam Profile Picture
    3,945 on at

    Hi Faisal ,

    actually i want to disable some menuitem button untill approve(button) is clicked , once the aprove is done , which all menuitem i have disabled should get enabled.

    But the problem is that in this  **AporovalEventHandler class i cannot write this enabling and disabling code as its showing error for these menuitem button that "variable is not declared"

    Thanks

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at

    In that case you just need to check the value of workFlowStatus filed from your table, If it is Approved then enable your button controls. I assume you have already set AutoDeclaration = YEs for your button controls on form.

  • Jonathan  Halland Profile Picture
    11,310 on at

    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.

  • Gautam Profile Picture
    3,945 on at

    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

  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    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

    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

  • Jonathan  Halland Profile Picture
    11,310 on at

    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

    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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans