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

To disable buton on form using the checkbox on custom form

(1) ShareShare
ReportReport
Posted on by 1,836
hi ,
Everyone ,
I have created the custom form where i have added the check box if i ticked the checked box create new in my custom form i need to disable the new button in sales order form .
do i need to code on sales order active method but how can i fetch the from control of my custom form.
here i my custom form .please guide me on this 
thanks,
Regard,
Dinesh
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    Yes, you'll want to check your condition when a sales order is selected, therefore in active().
     
    You didn't describe the logic you want, e.g. whether you want to somehow check warehouses of all lines in the given order, therefore I can't tell you exactly you can implement these unknown requirements. But in general, you'll decide which record in your table you're interested in, you'll find it (by find() method, select statement or so) and then you'll get the field value (e.g. myTable.MyField).
  • Waed Ayyad Profile Picture
    9,039 Super User 2025 Season 2 on at
    Hi
     
    Can you explain your requirements in another way, as your comment isn't clear?
     
     
    Thanks,
    Waed Ayyad
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi 
    Thanks
    For reply ,
    I was trying to enable and disable the button on current user but , the button add line on the salestable form is getting enable disable but the menuitem button is not getting disable as i have debugged the code debugger is hitting the condition . please guide me is anything i need to change to disable menuitem button .below is my code.
    [ExtensionOf(formdatasourceStr(SalesTable, SalesTable)) ]
    final class DTSalestableForm_AssignTransactionAccess_Extension
    {
        public int  active()
        {
            UserId    userid ;
            UserInfo  userInfo;
            DTSalesTransactionAccess      salesAccess;
            SalesTable        salesTableLoc = this.cursor();
            SalesLine         salesLine;
    
            int ret = next active();
    
            userid = curUserId();
            select id from  userInfo
                where userInfo.id == userid;
    
          while select * from salesAccess
                where salesAccess.UserId == userInfo.id
            {
                if(salesAccess.RecId != 0 && salesAccess.inventLocationId == salesTableLoc.InventLocationId)
                {
                  
                     
                        if(salesAccess.Addlines == NoYes::Yes)
                        {
                            this.formrun().design().controlName(formControlStr(SalesTable, LineStripNew)).enabled(true);
                        }
                        else
                        {
                            this.formrun().design().controlName(formControlStr(SalesTable, LineStripNew)).enabled(false);
                        }
    
                   
                        if(salesAccess.Confermation == NoYes::Yes)
                        {
                            this.formrun().design().controlName(formControlStr(SalesTable, buttonUpdateConfirm)).enabled(true);
                        }
                        else
                        {
                            this.formrun().design().controlName(formControlStr(SalesTable, buttonUpdateConfirm)).enabled(false);
                        }
    
                       
                 
                }
                else
                {
                    this.formrun().design().controlName(formControlStr(SalesTable, LineStripNew)).enabled(true);
                    this.formrun().design().controlName(formControlStr(SalesTable, buttonUpdateConfirm)).enabled(true);       
                }
            }
               
            return ret;
        }
    
    }
     
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at
    You're lucky! If you believed that your code worked and shipped it, you would break your customers ERP system! You must be more careful.
     
    There already is standard logic to decide whether a confirmation can be posted, which your completely ignore. If you managed to overwrite the value, you'd have break the standard logic. Also, if you want to prevent confirmation posting, you need to take all the related buttons into account. All the button will be handled if you do it at the right place: SalesTableType.canConfirmationBeUpdated(). What you should have done is considering that standard logic may exist (if you don't already know that the buttons are disabled in some case, which proves that some logic must exist). Then you should have used Find references to find the place and analyze code further to find the right place to extend.
     
    Your handling of LineStripNew is wrong too. I'm assuming that you want to prevent line creation, but you didn't. You disabled a button but users can still use keyboard shortcuts. The correct approach is using allowCreate() of salesLine_ds.
     
    Also, the while select makes no sense, because only values from the last record will be used. Loading all the previous records is a waste of resources. If there are more records in DTSalesTransactionAccess for a single user, add condition to your code to decide which one to use.
     
    You can throw away your select of userInfo and the salesLine variable.
     
    If accessing the button was the correct thing to do, you could greatly simplify your code by using element object to access the form. Then you can use, for example, element.buttonUpdateConfirm to access the confirmation button.

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
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans