Create dynamics NAV error message when sales amount is 0

Hi everyone , I'm relatively new to NAVISION world , I have a question i will be very grateful if someone can help me.

I have to create an error message that block a user when he tries to validate an sales invoice with 0 amount.

I'm sure I will be use an IF with Error msg like this :

SalesHeader.SetRange("No.", "Document No")

SalesHeader.Find('-')

If SalesHeader.Amount=0

then begin

Error('The Amount of the relate order "No.":=' +SalesHeader."No."+' cannot be 0.')

but I don't know where I will put that is on a code unit or on the order page ?

thanks for your help.

Kind regards

Answers

  • angelreynosogangelreynosog Member Posts: 9
    Hello, In the trigger of the validation of the sales invoice, put this code to see if it works ... I hope so.

    IF "Amount Including VAT" = 0 THEN
    BEGIN
    ERROR('Error Message Text');
    END
    ELSE BEGIN
    EXIT;
    END;


  • rahul_narangrahul_narang Member Posts: 1
    Hello @NavNewbie92. Can you tell me which version are you using of NAV?

    Also whichever version you are using after 2013R2 till 2016 you have the below option
    1) There is a post button on the Sales Order Page, you can write this code there before the program goes into the Sales-Post Codeunit. This will not allow the user to post the document until they bypass your error statement. Hope so i was clear in explaining you the answer in short.

    If you are using NAV 2016 and above you have 2 options
    1) Same as option 1
    2) You can create a code unit, create a function inside the code unit which will be a "Subscriber" function (Since you are a new bie, i am not completely sure if you know about Subscriber Functions, if not please search it once on the web, they are the way forward). In this subscriber function you will set the property of this function to trigger when the "OnBeforePost" Publisher is hit.
    ~~ Jack of all, Master of NAV! ~~
Sign In or Register to comment.