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 ?
  • Suggested answer
    Anton Venter Profile Picture
    19,542 Super User 2025 Season 1 on at
    Stop SalesCreateQuotation form from closing based on dialog output
    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
     
  • Martin Dráb Profile Picture
    231,766 Most Valuable Professional on at
    Stop SalesCreateQuotation form from closing based on dialog output
    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.
  • Tapiwa_Louis Profile Picture
    on at
    Stop SalesCreateQuotation form from closing based on dialog output
    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.");
            }       
            
            
        }
    
     
  • Suggested answer
    Anton Venter Profile Picture
    19,542 Super User 2025 Season 1 on at
    Stop SalesCreateQuotation form from closing based on dialog output
    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?

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,886 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,766 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans