Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Mandatory value before posting invoice

Posted on by Microsoft Employee

Hi  in the Sales Line Record table (form 47 sales invoice subform) I want to add field called Old Item Return a Boolean value, this needs to be checked

before posting the Invoice at each line for the sales line item. How can I make mandatory to choose, Yes/NO/Blank (defaultvalue) and this is the requirement.. Thanks

*This post is locked for comments

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Mandatory value before posting invoice

    Use

    IF ((SalesLine."Old Battery Value" <=0) and (SalesLine."Old Battery Type"=' ')) THEN

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Mandatory value before posting invoice

    thanks I tired and got work. and im writing for 1 requirement i got this error

    IF (SalesLine."Old Battery Return" = SalesLine."Old Battery Return"::Yes) THEN

    IF (SalesLine."Old Battery Value" <=0 and SalesLine."Old Battery Type"=' ') THEN

     ERROR(STRSUBSTNO(NATSGES_Text002));

    im checking whether old item return if yes check the old item value(decimal)

    and old battery type (text), unfortunately im getting error

    Type conversion is not possible because 1 of the operators

    contains and invalid type

    Interger and Text

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Mandatory value before posting invoice

    Good try. :)

    Actually you don't have to write TESTFIELD if you are using the IF condition. You are doing almost the same thing in here.

    Since you are using a option field you need to write your code like below.

    IF (SalesLine."Old Battery Return" = SalesLine."Old Battery Return"::"")  THEN

      ERROR('Throw your error here');

    But mind you, with this code you will not get 3 error messages for your 3 sales lines. At the first error occurred NAV will rollback the transaction and will throw the first error.

    So think if the user correct only the first line, and then try to post it, then error will throw for second line.

    That is how it works.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Mandatory value before posting invoice

    thank you for understanding.

     

    As "Old Battery Return" is an option field, you have to use

    IF (SalesLine."Old Battery Return" = SalesLine."Old Battery Return"::"") THEN

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Mandatory value before posting invoice

    Agree with your approach.. and im tyring now..


    IF ("Document Type" = "Document Type"::Invoice) THEN BEGIN
    SalesLine.FINDSET;
    REPEAT
    SalesLine.TESTFIELD("Old Battery Return");


    IF (SalesLine."Old Battery Return" ='') THEN
      ERROR(STRSUBSTNO(NATSGES_Text001, SalesLine."No."));

     
    //TESTFIELD(SalesLine."Old battery Return"); //"Old Item Return" is Field Name
    UNTIL (SalesLine.NEXT = 0);
    END;

    and im getting the below error

    type conversion is not possible because 1 of the operators
    contains an invalid type

    Option=Text

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Mandatory value before posting invoice

    Please try yourself first and let us know what you have tried.

    Don't expect code solutions for all problems from forum.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Mandatory value before posting invoice

    1. This works fine and thanks a lot for helping me, but I want to dispaly a msg, when the no value is filled, Msg should be "pls select the old item value"  and as well as a confirmation msg that you have selected the old item return value for this itemcode.

    This msg will be displayed if 3 times, if there are 3 salesLine.

    2. if the users select old item return value, there is another c text column called SlNo, this also need to be validate, only if the user select Yes in the Old item return value field.

    Appreciate your help.. or do you want me to create a new forum theard for this.

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at
    RE: Mandatory value before posting invoice

    Issue in the line below the Repeat. You need to correct your TESTFIELD with below code.

    SalesLine.TESTFIELD("Old Battery Return");

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Mandatory value before posting invoice

    The statement below Repeat should be

    SalesLine.TESTFIELD("Old Battery Return");

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Mandatory value before posting invoice

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans