automatic filling of fields in the item journal line

kanika
Member Posts: 247
Hi experts!! NAV2017
In the Item Journal Line I have a new field "No Etiqueta", TableRelation Etiquetas (50000)
I need that when the field Etiqueta are validated the fields "Order No", "Document No" and "Item No"
are automatically filled getting the data from the Product Order Line table
My code:
No. Etiqueta - OnValidate()
Etiquetas.SETRANGE("No. Etiqueta","No. Etiqueta","No. Etiqueta");
ProOrdLine.SETFILTER("Item No.",Etiquetas."No. Referencia");
ProOrdLine.SETFILTER("Starting Date",'<=%1',WORKDATE);
"Posting Date":=WORKDATE;
"Item No.":=Etiquetas."No. Referencia";
"Order No.":=ProOrdLine."Prod. Order No.";
"Document No.":=ProOrdLine."Prod. Order No.";
But does nothing.
In the Item Journal Line I have a new field "No Etiqueta", TableRelation Etiquetas (50000)
I need that when the field Etiqueta are validated the fields "Order No", "Document No" and "Item No"
are automatically filled getting the data from the Product Order Line table
My code:
No. Etiqueta - OnValidate()
Etiquetas.SETRANGE("No. Etiqueta","No. Etiqueta","No. Etiqueta");
ProOrdLine.SETFILTER("Item No.",Etiquetas."No. Referencia");
ProOrdLine.SETFILTER("Starting Date",'<=%1',WORKDATE);
"Posting Date":=WORKDATE;
"Item No.":=Etiquetas."No. Referencia";
"Order No.":=ProOrdLine."Prod. Order No.";
"Document No.":=ProOrdLine."Prod. Order No.";
But does nothing.
0
Best Answer
-
You have only filtered the ProdOrdLine, not retrieved one. You need some command like FIND, FINDFIRST or FINDLAST.5
Answers
-
I also need that instead of the "Today" put "Workdate" in"Posting Date" but it does not work either0
-
You have only filtered the ProdOrdLine, not retrieved one. You need some command like FIND, FINDFIRST or FINDLAST.5
-
OOOOHHHHHHHH!!! YES
SORRRYY
TOO MANY HOURS WORKING
WHAT A SHAME!!
0 -
this is the final code that works perfectly:
Etiquetas.SETRANGE("No. Etiqueta",Rec."No. Etiqueta",Rec."No. Etiqueta");
ProOrdLine.SETFILTER(Status,'Released');
ProOrdLine.SETFILTER("Item No.",Etiquetas."No. Referencia");
ProOrdLine.SETFILTER("Starting Date",'<=%1',WORKDATE);
IF ProOrdLine.FINDLAST THEN BEGIN
Rec."Posting Date":=WORKDATE;
VALIDATE(Rec."Posting Date");
Rec."Order No.":=ProOrdLine."Prod. Order No.";
VALIDATE(Rec."Order No.");
Rec."Document No.":=ProOrdLine."Prod. Order No.";
VALIDATE(Rec."Document No.");
Rec."Order Line No.":=ProOrdLine."Line No.";
VALIDATE(Rec."Order Line No.");
Rec."Item No.":=ProOrdLine."Item No.";
VALIDATE( Rec."Item No.");
Rec."Operation No.":='999';
VALIDATE(Rec."Operation No.");
Rec.Quantity:=Etiquetas.Cantidad;
VALIDATE(Rec.Quantity);
END;
Thanks for all!! and Merry chrystmas
0 -
Just want you to make aware that the construct:
Rec."Posting Date":=WORKDATE; VALIDATE(Rec."Posting Date");
works slightly different than simpleVALIDATE(Posting Date", WORKDATE);
In the former case with separate linws with the assignment and the VALIDATE call you may miss some validation code.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
How could that construct miss validation code? In both cases the field is validated with the same date and the code in the validate-trigger will be run. Or am I missing something?0
-
If the code inside the OnValidate trigger on a field includes
IF xRec.Field <> Field THEN BEGIN...
then the code inside the condition block bit will be always omitted if you validate the field like this:Field := 'Value'; VALIDATE(Field)
But if you validate like thisVALIDATE(Field, 'Value')
then the chances are that the validation code will be executed.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions