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:
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?
“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!