Problem with a code
Leroy
Member Posts: 199
Dear folks, I've the following code on OnValidate trigger from "Qty. to Receive" field from "Purchase Line" table:
I want simply that shows a message when the quantity that you put on this field manually should be more than 0, but it occurs something strange; it shows me the message when I put a quantity on Quantity field, not in 2Qty. to Receive" (it is on 0). Does anybody knows what's the problem?.
Thanks in advance.
IF ("Qty. to Receive"<>0)
THEN MESSAGE:='text';
I want simply that shows a message when the quantity that you put on this field manually should be more than 0, but it occurs something strange; it shows me the message when I put a quantity on Quantity field, not in 2Qty. to Receive" (it is on 0). Does anybody knows what's the problem?.
Thanks in advance.
0
Comments
-
Quantity-OnValidate does a VALIDATE of "Qty. to Receive".
You should change your code toIF CurrFieldNo = FIELDID("Qty. to Receive") THEN IF ("Qty. to Receive"<>0) THEN MESSAGE:='text';Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks for repy, but, what have I to put in FIELDID, please?.0
-
FIELDID is method of the Rec. variable returning ID of the field entered as parameter, you do not need to enter anything...
0 -
Thanks, but the problem is that doesn't run, it shows an error on FIELDID on saving; what's the problem please?.
Thanks for help in advance.0 -
My error :oops:
FIELDID must be FIELDNORegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:My error :oops:
FIELDID must be FIELDNO
I didn't notice that too... 8)0 -
Thanks for reply, no problem; but now it doesn't show me any message when I put something in "Qty. to Receive" field. Any idea please?.
Thanks in advance.0 -
May be you need to use
Message(TextConstant);
and not assigning some text to some variable... ;-)
We assumed that the message is some variable which is used in some way after the text is assigned...
But it depends on rest of the code...0 -
Thanks for reply; the whole code (on the beggining from "Qty. to Receive" OnValidate trigger) is this:
IF CurrFieldNo = FIELDNO("Qty. to Receive") THEN IF ("Qty. to Receive"<>0) THEN BEGIN MESSAGE:='You must charge 2€ to the unit cost'; END;
I don't use a variable for the message. Any idea about it please?.
Thanks for help.0 -
Sorry :oops: , I see what's my problem. I add another condition. I mean. The real code is
IF CurrFieldNo = FIELDNO("Qty. to Receive") THEN IF ("Qty. to Receive"<>0) AND (Item.Tooling=TRUE) THEN BEGIN MESSAGE:='You must charge 2€ to the unit cost'; END;
I add the condition "AND (Item.Tooling=TRUE)". If I don't put it It works perfectly, but if I put it doesn't do anything. How can I put this new condition?.
Thanks for your help.0 -
1) When using boolean variable in condition, you do not need to use =true or =false.
IF ("Qty. to Receive"<>0) AND Item.Tooling THEN //or AND (not Item.Tooling) if you need to test for FALSE2) Never use hardcoded text constants when the text will be used in GUI (shown to user). Use the text constant to be able to use different translations (be prepared for multilanguage). It means define the text constant with the text and instead the string assign the text constant in the code.
3) If you want to test something on the Item variable, you need to get some record into it first. it means you need to use e.g. Item.GET("No.") before using the Item... ;-)0 -
Ooops :oops: ,shit..., as you say on point 3 I needed initialize the Item table; I had it initialized in a trigger before, but it seems like don't keep it. It works perfectly now =D> .
Thank you very much for help and your time.0 -
When you compare some record then you have to keep and 2 way to keep then
1.) First you can be use GET method for if you know primary key (first field).
2.) Second you can use FILTER of that table and then apply FINDFIRST.Zephyr0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 250 Dynamics CRM
- 102 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
