Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to throw error on click of button even if single SalesQuotationLine has value for Config Id

(0) ShareShare
ReportReport
Posted on by 64

Hi,

I am working on a task where I need to throw an error even if a single SalesQuotationLine has a value for Config Id field.

So, for this I have write code on Onclicked event of confirm Button & the config Id field is coming from InventDim Datasource of SalesQuotationTable Form.

I need to stop the confirmation status of this Quotation & throw error if line has config Id filled with value, but this code is not working as expected.

[FormControlEventHandler(formControlStr(SalesQuotationTable, ButtonUpdateConfirmation), FormControlEventType::Clicked)]
    public static void ButtonUpdateConfirmation_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        InventDim inventDim = sender.formRun().dataSource(4).cursor();
        SalesQuotationLine salesQuotationLine = sender.formRun().dataSource(2).cursor();

        while select salesQuotationLine join inventDim where inventDim.inventDimId == salesQuotationLine.InventDimId
        {
            if(inventDim.configId)
            {
                throw Error(" Is not a product master");
            }

 

        }



    }

Confirm_5F00_Button_5F00_SQF.jpg

Thanks,

Rahul

  • Rahul Dahiya Profile Picture
    64 on at
    RE: How to throw error on click of button even if single SalesQuotationLine has value for Config Id

    Hi Martin,

    Thanks for this solution.

    I tried to write code in button as well, that was actually act too slow & not working as expected.

    I write code in validate method of SalesQuotationEditLinesForm class & its working now.

    Thanks,

    Rahul

  • Verified answer
    Martin Dráb Profile Picture
    234,595 Most Valuable Professional on at
    RE: How to throw error on click of button even if single SalesQuotationLine has value for Config Id

    The class called by ButtonUpdateConfirmation is SalesQuotationEditLinesForm.

    You'll need to decide when you want to run your validation. Don't forget that posting may include several quotations and that records may be selected from a query when running the posting (in such a case, you don't know the quotations when pressing the button).

  • Verified answer
    Martin Dráb Profile Picture
    234,595 Most Valuable Professional on at
    RE: How to throw error on click of button even if single SalesQuotationLine has value for Config Id

    Your code likely runs too late. Business logic doesn't belong on clicked() anyway. Instead, look at the standard code for confirmation and put the logic there. It's likely done through the FormLetter framework.

    Putting code at the right place will also resolve the problem of identifying table buffers by hard-coded IDs of form data sources.

    There is need for a while loop. You can simply check if there is any line with configId and throw an error if it is.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans