Convert Integer to Code
FPoco
Member Posts: 35
Hi forum
how I make to convert an integer field into a code field?
thanks
how I make to convert an integer field into a code field?
thanks
0
Comments
-
-
I can do for that way ??
count := 0;
if find ('-') then
repeat
count += 1
until next = 0;
code := FORMAT(count);0 -
Format does the job, but what are you trying to do exactly?0
-
I need to compose a numerator where one another one has a fixed part that will be id of the user and another one who will be an count, must have this aspect xxxabc0010
-
FPoco wrote:I need to compose a numerator where one another one has a fixed part that will be id of the user and another one who will be an count, must have this aspect xxxabc001
Why not just add the user ID to the table, and if your Numerator (My Code) is not the primary key then something like:
SETCURRENTKEY("USER ID",My Code");
SETRANGE("USER ID",USERID);
IF FINDLAST THEN
NextMyCode := INCSTR("My Code")
ELSE
NextMyCode := USERID + '001';
MyRecVariable.INIT;
MyRecVariable."My Code" := NextMyCode;
MyRecVariable."USER ID" := USERID;
MyRecVariable.INSERT;
Or another option if you are using the user setup table, is to create a field and use a number series for each user and the NoSeriesManagement code unit to return the next number!
with a Starting Number of xxxabc000 then it is easy to change if the requirement changes.
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
Would a FINDLAST or a FIND('+') and then an INCSTR on the code work?
Rec.SETFILTER(field,xxx);
IF Rec.FINDLAST THEN
BEGIN
newcode := INCSTR(Rec.actualcode);
END;
Maybe it will, maybe it wont?0 -
the id is not id of navision is of a new table that I only created for this program. This will go to identify the referring user in the numerator. The first part of the numerator is a field text but fixed it will not go to suffer to alterations the second part will be selected by the people whom the numerator will create and third he will be the accountant who will go being developed consonant its use.0
-
FPoco wrote:the id is not id of navision is of a new table that I only created for this program. This will go to identify the referring user in the numerator. The first part of the numerator is a field text but fixed it will not go to suffer to alterations the second part will be selected by the people whom the numerator will create and third he will be the accountant who will go being developed consonant its use.
Same Code!
MyRecVariable.SETCURRENTKEY("My User ID",My Code");
MyRecVariable.SETRANGE("My User ID",MyTableUser.ID);
MyRecVariable.IF FINDLAST THEN
NextMyCode := INCSTR(MyRecVariable."My Code")
ELSE
NextMyCode := MyTableUser.ID + '001';
MyRecVariable.INIT;
MyRecVariable."My Code" := NextMyCode;
MyRecVariable.INSERT;
As I said in my last post, I would use the number series, if it is by user then add a field "No. Series" to your new user (Accountant) table, then your code will be like this:
The starting number per user would be Constant + New User ID + 000 = 'xxxaaa000'
MyTableUser.TESTFIELD("No. Series");
MyRecVariable.INIT;
MyRecVariable."My Code" :=
NoSeriesMgt.GetNextNo(MyTableUser."No. Series",TODAY,TRUE);
MyRecVariable.INSERT;
UserA
xxxUserA001
xxxUserA002
xxxUserA003
UserB
xxxUserB001
xxxUserB002
xxxUserB003
You can use the one number series for all users starting at say 100
MyTableUser.TESTFIELD("No. Series");
MyRecVariable.INIT;
MyRecVariable."My Code" := Constant + MyTableUser.ID +
NoSeriesMgt.GetNextNo(MyTableUser."No. Series",TODAY,TRUE);
MyRecVariable.INSERT;
This will cause sorting problems due to your structure!
xxxUserA101
xxxUserA104
xxxUserB102
xxxUserB105
xxxUserC103
Consider "Entry No." as a primary key, then a secondary key with the New user ID, and a composite field created on insert, Constant + MyUser.ID+ FORMAT("Entry No.");
Then you can sort as entered or by your composite Field!Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
MTC wrote:Would a FINDLAST or a FIND('+') and then an INCSTR on the code work?
Rec.SETFILTER(field,xxx);
IF Rec.FINDLAST THEN
BEGIN
newcode := INCSTR(Rec.actualcode);
END;
Maybe it will, maybe it wont?
It will!
Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
OK but i can do it in a form??
I have a problem whit the count0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 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
