synchronize number series

Hello everybody,

I would be very grateful for some help with this.

Situation: Tables contact and customer both use their own numberseries. However, they are not necessarily in sync. Actually, they are most often not in sync because there are more contacts than customers. However, we would like to have the same primary key value for both tables for companies. Therefore, whenever a new contact of type company is created, the newly assigned contact number should also be used as the next available customer number.

My solution approach: Currently, in the OnInsert trigger of the contact table I read the new contact number and I am trying to set the “Last No. Used” of the customer series (CN) to the identical value, like so (with myNoSeriesLine being a record of type ‘No. Series Line’ :

IF myNoSeriesLine.GET(‘CN’) THEN
myNoSeriesLine.“Last No. Used” := “No.”;

However, nothing happens. Also, no error is thrown.

I see two problems, that I cannot solve:

  1. the primary key of the NoSeriesLine table is of datatype CODE(10). How can I GET the respective record by passing a string (‘CN’) ?.. Is some type of conversion necessary?

  2. “Last No. Used” in the NoSeriesLine table is also of type CODE(30). I cannot assign an integer value to it although its numerical and supposed to increase by 1 automatically if used with the default behavior. How do I convert the integer value into a CODE and how to I increase it by 1 first?

Potentially, my approach is also suboptimal.

Any help is greatly appreciated!


May be you are not modifying your No. Series series

IF myNoSeriesLine.GET(‘CN’) THEN BEGIN
myNoSeriesLine.“Last No. Used” := “No.”;



thank you! that, together with the fact that I needed to pass a second parameter for the primary key (the line number 10000) solved my problem, e.g.:

IF myNoSeriesLine.GET(‘CN’,10000) THEN BEGIN
myNoSeriesLine.“Last No. Used” := “No.”;

Now, the only thing that remains is how do I perform an addition/substraction on a a numeric CODE field?

e.g: “MyCodeField” + 1 ?

Did you try

NewString := INCSTR(String);

Thank you all! It is solved. I’m new to Navision and I didn’t realize I can convert an integer to code using Format or INCSTR.

Thanks a lot, greatly appreciated!


EVALUATE(myCodeInteger, “No.”);
myCodeInteger := myCodeInteger - 1;
IF myNoSeriesLine.GET(‘CN’,10000) THEN BEGIN
myNoSeriesLine.“Last No. Used” := FORMAT(myCodeInteger);