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

Stop SalesCreateQuotation form from closing based on dialog output

(1) ShareShare
ReportReport
Posted on by
Hi Guys,
 
I have have requirement where when creating a Quotation using the SalesCreateQuotation form, when the OK button is clicked a YesNo dialog should pop-up confirming some details. This YesNo Dialog pops over the SalesCreateQuotation dialog form. If the user clicks Yes, the normal flow should continue, however, if the user clicks No on the YesNo Dialog the SalesCreateQuotation should remain open so the user can correct sales-quotation-header information entered. 
 
Currently I am able to show the YesNo Dialog prompting the user for clarity.
 
Please assist me, How can I stop the SalesCreateQuotation form from proceeding with its normal flow after the user clicks No on the YesNo Dialog ?
I have the same question (0)
  • Suggested answer
    Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at
    Hi,
     
    The canClose() form method is perfect for this, depending on when this method is called, you can try to override it to stop the form from being closed in certain cases. Usually logic is placed there to allow or prevent the form closing. How / where do you show your dialog prompt?
  • Tapiwa_Louis Profile Picture
    on at
    hi @Anton, I managed to call my dialog within the eventHandler code for the OK button as shown below. Any idea how I can call the canClose() bit ?
     
     
    [FormControlEventHandler(formControlStr(SalesCreateQuotation, OK), FormControlEventType::Clicked)]
        public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            boolean ret = true;
            
    
            Args args = new Args();
            FormCommandButtonControl  callerButton = sender as FormCommandButtonControl;
    
            FormControlEventArgs formControlEventArgs = e as FormControlEventArgs;
    
            DialogButton     diagBut;
            str amountvalue = int2str(25);//pass the total amount value
    
    
            //Retrieves the button that we're reacting to
            FormRun form = callerButton.formRun(); //Gets the running SalesEditLines form
    
            //Get the salesId that was selected in the SalesEditLines form
            FormDataSource salesQuotationTable_ds = form.dataSource(formDataSourceStr(SalesCreateQuotation, SalesQuotationTable )) as FormDataSource;
            SalesQuotationTable salesQuotationTable = salesQuotationTable_ds.cursor();
                   
            
            str strMessage = strfmt("Please confirm Customer Reference '%1' is correct.", salesQuotationTable.CustomerRef);
    
            str strTitle = "Customer Reference Confirmation.";
    
            diagBut = Box::yesNo(strMessage, dialogButton::No, strTitle);
    
            if (diagBut == DialogButton::No)
            {
                ret = checkFailed("Provide the correct Customer Reference to proceed.");
    
                //here is where i need the code to prevent the SalesCreateQuotation from closing
            
            }
            else if(diagBut == DialogButton::Yes)
            {
                ret = true;
            }
            else
            {
                ret = checkFailed("Operation canceled.");
            }       
            
            
        }
    
     
  • Martin Dráb Profile Picture
    238,000 Most Valuable Professional on at
    Doing it on clicked() method (or the event handler) is a bad idea. You should change the logic executed by the button, not the button itself.
     
    I would have to look into code, but I'm assuming you should extend a validation method of the form letter class.
  • Suggested answer
    Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at
    I'm afraid the Clicked event handler of the OK button is called after the form's canClose method is called (by the system/kernel/application).
     
    An alternative is to hide the standard OK button and add your own button. The comment below in your code is technically not correct by the way. It's the SalesCreateQuotation form.
     
    //Gets the running SalesEditLines form
     

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
Abhilash Warrier Profile Picture

Abhilash Warrier 677 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 339 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans