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 :
Microsoft Dynamics NAV (Archived)

How to validate payments?

(0) ShareShare
ReportReport
Posted on by 428

I have put some validation in the 'POS Transaction line'.'Amount in Currency' field.

I am trying to display the mode of payment while punching the payment.

I written as:

IF "Entry Type"=Rec."Entry Type"::Payment THEN 

 MESSAGE('%1',"Entry Type");

Why it is not working while punching payment in the POS.

I noticed no validation works if we are punching payments. Validation works perfect if we punch item.

How to validate payments?

Regards,

Abdul.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    In which object and which trigger you wrote the code? While you punch the payment (Entering some value in Amount in Currency field) the message should appear right?

    Try writing on the relevant Table and on OnValidate() trigger.

    Your code must work, but I am not sure how good it has been structured. Please attach screenshots?

    IF "Entry Type" = "Entry Type"::Payment THEN

    MESSAGE(FORMAT("Entry Type"));

    This code will work too.

    Hope it helps.

  • Verified answer
    Amol Salvi Profile Picture
    18,698 on at

    Hi Abdul,

    On which trigger you have write your code . You need to write your code on correct trigger to execute .

    If you see the code execute when item is entered is written on onvalidate trigger

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    In which table you have added the validation? Because as per my understanding there is no Entry type:: Payment in the 81 table which use for cash receipt journal.

    If this is a modified or new table then I do not see an error in your code. Only thing I can guess is you have written it on a wrong trigger. As per your requirement you need to write the code on the OnValidate() trigger of the  field you have key in the data. Once the user complete the key in data for that particular field and move to another field (lost focus), NAV will trigger the OnValidate() trigger.

  • AbduTeeyech Profile Picture
    428 on at

    Hi All,

    I am trying in table '99008981 (POS Trans. Line).

    Below is the code I written in Amount In Currency - OnValidate() trigger.

    -----------------------------------------------------------

    Amount In Currency - OnValidate()

    IF "Entry Type"=Rec."Entry Type"::Payment THEN BEGIN

    MESSAGE('%1',format("Entry Type"));

    IF Number='11' THEN BEGIN

     IF "Amount In Currency" MOD 50 <> 0 THEN

      ERROR ('Amount is not divisible by 50');

    end;

    END;

    --------------------------------------------------------

    While punching the payment with the amout 40, nothing shows. Neither  MESSAGE('%1',format("Entry Type")) gets displayed, nor    ERROR ('Amount is not divisible by 50') works

    Abdul.

  • Verified answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    IF "Entry Type"=Rec."Entry Type"::Payment THEN
    BEGIN
       MESSAGE('%1',format("Entry Type"));
       IF Number='11' THEN
       BEGIN
          IF "Amount In Currency" MOD 50 <> 0 THEN
             ERROR ('Amount is not divisible by 50');
       END;
    END;

    If this is your code, there can be few points that your code may fail.

    1. Entry Type is not Payment - If this is the case, then both your MESSAGE and ERROR will not execute.

    2. Number is not equal to 11.

    There can be other implications too. Please debug your code.

  • AbduTeeyech Profile Picture
    428 on at

    Hi Nareshwar,

    even if the  'Number' is not 11, then it should at least display the message right? (  MESSAGE('%1',FORMAT("Entry Type"));  )

    In my POS Trans. Line table, the 'Entry type' is 'Payment' and 'Number' is 11.

    'POS Trans. Line' table records available in the screen shot.

    But, still the validation not working.

    Validation-error.jpg

    I can tell you another thing, that, I have put same codes inside the onvalidate of Qty. column.

    Same happens for entry-type:'payments'. For entry-type:'Items', the validation in the Qty column works good.

    Some thing smells not-normal.

    Regards,

    Abdul.

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    I would add a new message box to your code to check, if the code really get execute. I think you need to debug your code and see for possible issues. Looking at your code I do not see any issue for its not getting executing.

    As I previously said in my reply, only thing I can think of is that trigger issue. If you can post a screenshot of the code where you have written and the place you actually enter the data, we will be able to provide more input to this. 

    MESSAGE('%1','Trigger execute');
    IF "Entry Type"=Rec."Entry Type"::Payment THEN 
    BEGIN
       MESSAGE('%1',format("Entry Type"));
       IF Number='11' THEN
       BEGIN
          IF "Amount In Currency" MOD 50 <> 0 THEN
             ERROR ('Amount is not divisible by 50');
       END;
    END;


  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    Hi Abdul,

    Where you have written code  ?

    Is it on Page or Table  on validate trigger???

  • AbduTeeyech Profile Picture
    428 on at

    Hi Tharanga/ Amol,

    Below is the screen shot of 'Amount In Currency' on validate.

    Qty-Valdn.jpg

    And, below  message I put in 'Quantity - OnValidate()', also NOT displaying while punching the 'Payments' in the POS. And it displays if I punch an 'item' in the POS.

    Qty-Valdn.jpg

    Regards,

    Abdul.

  • Verified answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at

    Thank you for the screenshots. Is the first message box in the "Amount In Currency" get execute? If it is not getting executed then it is a bit problem, because no matter your conditions first message box should execute at the time of you stop typing anything in the "Amount in Currency" field and move out of it.

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans