Hi,
I have a No. field that must be incremented everytime whenever data is inserted. I follow the link below to increment. But couldn't even find a value in the field.
Actually the scenario is that i have to copy order lines of 1st sales order
and then from the 2nd sales order to the third Sales Order. So i have created
the Line No. to get a sequence like 10,20,30....and so on
I have created 2 new fields in table:
1. Line No. (that i want to increment)
2. No. Series (Table Relation - "No. Series")
As per the blog i wrote following code:
1. Line No. - OnValidate
IF "Line No." <> xRec."Line No." THEN BEGIN
SalesSetup.GET;
NoSeriesMgt.TestManual(SalesSetup."Prod. Order Routing Line No");
"No. Series" := '';
END;
2. OnInsert() Trigger:
IF "Line No." = 0 THEN BEGIN
SalesSetup.GET;
SalesSetup.TESTFIELD("Prod. Order Routing Line No");
NoSeriesMgt.InitSeries(SalesSetup."Prod. Order Routing Line No",xRec."No. Series",0D,"Routing No.","No. Series");
END;
3. AssistEdit()
WITH recProdOrRouLine DO BEGIN
recProdOrRouLine := Rec;
SalesSetup.GET;
SalesSetup.TESTFIELD(SalesSetup."Prod. Order Routing Line No");
IF NoSeriesMgt.SelectSeries(SalesSetup."Prod. Order Routing Line No",OldrecProdOrRouLine."No. Series","No. Series") THEN BEGIN
NoSeriesMgt.SetSeries("No.");
Rec := recProdOrRouLine;
EXIT(TRUE);
END;
END;
Comments
http://ssdynamics.co.in
and then from the 2nd sales order to the third Sales Order. So i have created
the Line No. to get a sequence like 10,20,30....and so on
I have created 2 new fields in table:
1. Line No. (that i want to increment)
2. No. Series (Table Relation - "No. Series")
As per the blog i wrote following code:
1. Line No. - OnValidate
IF "Line No." <> xRec."Line No." THEN BEGIN
SalesSetup.GET;
NoSeriesMgt.TestManual(SalesSetup."Prod. Order Routing Line No");
"No. Series" := '';
END;
2. OnInsert() Trigger:
IF "Line No." = 0 THEN BEGIN
SalesSetup.GET;
SalesSetup.TESTFIELD("Prod. Order Routing Line No");
NoSeriesMgt.InitSeries(SalesSetup."Prod. Order Routing Line No",xRec."No. Series",0D,"Routing No.","No. Series");
END;
3. AssistEdit()
WITH recProdOrRouLine DO BEGIN
recProdOrRouLine := Rec;
SalesSetup.GET;
SalesSetup.TESTFIELD(SalesSetup."Prod. Order Routing Line No");
IF NoSeriesMgt.SelectSeries(SalesSetup."Prod. Order Routing Line No",OldrecProdOrRouLine."No. Series","No. Series") THEN BEGIN
NoSeriesMgt.SetSeries("No.");
Rec := recProdOrRouLine;
EXIT(TRUE);
END;
END;
If you want to increment "Line No." in code you can look at http://www.dynamics.is/?p=248 and use
IF "Line No." = 0 THEN
"Line No." := NextLineNo;
where NextLineNo is a function similar to the example on my blog.
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com