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 :
Customer experience | Sales, Customer Insights,...
Answered

Disabled button on sales confirmation

(0) ShareShare
ReportReport
Posted on by 150

Hi ,

I have a work where i have to create transfer order after the sales order confirmation and also when sales order confirmation wil be done all button and all fields should be disabled.

So , I did a code on the ok click of SalesEditLine form but it did not work .

So, can please suggest me the correct way to do it.

I have the same question (0)
  • Verified answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Sam D,

    To disable all the fields after sales confirmation you can make use of "CustConfirmJour" table. This table will have all the sales order header which are confirmed. 

    You can write event handler for the form DataSource active method - In that event handler you can add a code to check if the current sales Id is present in "CustConfirmJour" table. If exist, then its confirmed and sales order and you can set allow edit to false for the data source otherwise true.

    Also, for transfer order there is in built feature enabled. Refer to the below link for explanation.

    https://exploredynamics365.home.blog/2020/06/07/transfer-order-from-sales-order-line-in-microsoft-dynamics-365-finance-and-supply-chain-management/

    Thanks,

    Girish S.

  • Sam D. Profile Picture
    150 on at

    Hi Girish S.

    Thank you this is really work for me to create transfer order , but i have to create transfer order through code i.e.  after confirmation of sales order there should be create transfer order and all button include pick , pack and invoice button should be disable

    and in which datasource i have to write the logic and how to disable .

    Is it CustconfirmJournal form ?

  • GirishS Profile Picture
    27,827 Moderator on at

    In which form do you want to disable the fields?

    I guess "CustConfirmJournal" form will show all the sales orders that are confirmed - Do you want to disable all the fields in this form?

    Thanks,

    Girish S.

  • Sam D. Profile Picture
    150 on at

    No , I want disabled all the fields and button of the Sales table form , but i am confuse where i have to write logic to disable all this after confirmation of sales order because the record also exists in cust confirm jour after confirmation

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    CustConfirmJour table will have records only after sales confirmation. So based on that table you can write the code on "onActivated" event handler method of the "SalesTable" data source.

    Try the below code by adding a one control and check if it works for your scenario - If it works you can add all the controls and set enable property to false.

    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
         SalesTable salesTable = sender.cursor();   
         FormDataSource salesTable_ds = sender.formRun().dataSource("SalesTable");
         FormRun element = sender.formRun();
         //you can get the control name like below
         FormControl controlName = element.design(0).controlName("ControlName");            
         
         //Initialize CustConfirmJour buffer.
         CustConfirmJour confirmJour;
         // add select statement to check whether the SalesTable record is there in CustCOnfirmJour table.
         Select * from confirmJour
            where confirmJour.SalesId == salesTable.SalesId;
        // if there is a record in the CustConfirmJour table then it means that
        // sales id is confirmed - So you can go ahead and disable all the controls.
        if(confirmJour.RecId)
        {
            controlName.enable(false);
            // you can add all the availble contols and set the enable property to No like above.
        }
    
    }

    Thanks,

    Girish S.

  • Sam D. Profile Picture
    150 on at

    That means i have to add one by one all control name respectively , is there any solution that we can disable all button in such a single way ?

    Because there are too many fields and also too many buttons are available.

  • GirishS Profile Picture
    27,827 Moderator on at

    I guess it's not possible. But you can get the group control and set the enable property. So, Button group control will have all the buttons. 

    I don't think this will work but you can try.

    [FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesTable), FormDataSourceEventType::Activated)]
    public static void SalesTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
    {
         SalesTable salesTable = sender.cursor();   
         FormDataSource salesTable_ds = sender.formRun().dataSource("SalesTable");
         FormRun element = sender.formRun();
         //you can get the control name like below
         FormControl controlName = element.design(0).controlName("ControlName");            
         //get the form group control.
         FormGroupControl group1 = element.design(0).controlName("Group control name");
         //Initialize CustConfirmJour buffer.
         CustConfirmJour confirmJour;
         // add select statement to check whether the SalesTable record is there in CustCOnfirmJour table.
         Select * from confirmJour
            where confirmJour.SalesId == salesTable.SalesId;
        // if there is a record in the CustConfirmJour table then it means that
        // sales id is confirmed - So you can go ahead and disable all the controls.
        if(confirmJour.RecId)
        {
            controlName.enable(false);
            //disable the group control
            group1.enabled(false);
            // you can add all the availble contols and set the enable property to No like above.
        }
    
    }

    Thanks,

    Girish S.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 146 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 59

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans