I am looking to add a confirmation dialog box to my Sales Order Header page if a user inputs an unexpectedly large amount.
For example, if a user enters in a sales order with an amount of $50,000 I want a message to display in the RTC that asks the user if they would like to proceed.
I have written the below C/AL code which I’m sure is wrong. I would be very appreciative if someone could point me in the right direction. Thanks!
Amount - OnValidate()
IF (“Amount” > 50000) THEN
BEGIN
IF DIALOG.CONFIRM (Text002,TRUE) THEN
ERROR(‘Request Cancelled’);
END;
Hi [mention:81eae18f857e4535929d7020ce75da2b:e9ed411860ed4f2ba0265705b8793d05]
Thank you for your reply.
Amount - OnValidate()
IF (Amount > 50000) THEN
IF NOT CONFIRM(Text002) THEN
ERROR(‘Request Cancelled’);
I have added the above code to my Sales Order Header page. I, unfortunately, don’t see any message appear when the user enters an amount greater than 50000
I guess I should base this logic around a different field.
Perhaps the Line Amount of the Sales Lines page would be more appropriate?
Line Amount - OnValidate()
IF (“Line Amount” > 50000) THEN
IF NOT CONFIRM(Text002) THEN
ERROR(‘Request Cancelled’);
I’ve tried adding the above but I think I am still missing something. Basically just looking for a way to warn a user if a dollar amount > 50000 appears anywhere on a Sales Order.
Not recommend to hardcode amount ( 50000 ) in codes Create one setup in Sales & Receivables Setup
Create one codeunit and subscribe Sales Line OnAfterUpdateVATAmounts function
LOCAL [EventSubscriber] OnAfterUpdateVATAmounts(VAR SalesLine : Record "Sales Line")
IF SalesLine."Document Type" <> SalesLine."Document Type"::Order THEN
EXIT;
SalesReceivablesSetup.GET();
IF SalesReceivablesSetup."SO Warning Amount" = 0 THEN
EXIT;
SalesHeader.GET(SalesLine."Document Type",SalesLine."Document No.");
SalesHeader.CALCFIELDS(Amount);
IF (SalesHeader.Amount > SalesReceivablesSetup."SO Warning Amount") THEN
IF NOT CONFIRM(Text001) THEN
ERROR(Text002);
Have you tried to debug the code? Set a breakpoint on the publisher, and see if it doesn’t take you there. You can also check the list of event subscribers. I have experienced subscribers which have been failing because of “something”. And in that case the event subscriber list may tell you the reason.
Hi [mention:61b2aa9ce72e429baa1ef43208ddbea4:e9ed411860ed4f2ba0265705b8793d05]
I don’t see any errors when I look at the Event Subscribers. I have modified the code slightly so that it is an exact match of the suggestion provided by another user at the beginning of this thread. I need to better familiarize myself with the debugger. Hopefully, that will allow me to see what’s wrong. Thanks