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, ...
Answered

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

(0) ShareShare
ReportReport
Posted on by 70

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

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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.

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    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).

  • Rahul Dahiya Profile Picture
    70 on at

    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

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 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans