How to copy field to another

nikeman77
Member Posts: 517
hi all,
I have a field as follows:
FieldNAME: Source | Modified By | Modified Date
DataType: (Code50) | (Code(20) | DateTime
Sample1 : dynmicsusr21 19/01/12 09.01 33PM | |
Sample2: dynmicsusr2119/01/12 05:02 55AM | |
Expected dynmicsusr21 19/01/12 09.01 33PM | dynmicsusr21 | 19/01/12 09.01 33PM
result dynmicsusr2119/01/12 05:02 55AM | dynmicsusr21 | 19/01/12 05:02 55AM
How to achieve it ? Note that Sample1 is with space between UserID and DateTime, Sample2 is with NO space.
The good news is that ALL UserID is the same (in this case we use dynamicsusr21).
I have a field as follows:
FieldNAME: Source | Modified By | Modified Date
DataType: (Code50) | (Code(20) | DateTime
Sample1 : dynmicsusr21 19/01/12 09.01 33PM | |
Sample2: dynmicsusr2119/01/12 05:02 55AM | |
Expected dynmicsusr21 19/01/12 09.01 33PM | dynmicsusr21 | 19/01/12 09.01 33PM
result dynmicsusr2119/01/12 05:02 55AM | dynmicsusr21 | 19/01/12 05:02 55AM
How to achieve it ? Note that Sample1 is with space between UserID and DateTime, Sample2 is with NO space.
The good news is that ALL UserID is the same (in this case we use dynamicsusr21).
0
Answers
-
Not sure what you want here?
"Modified By" := USERID; "Modified Date" := CURRENTDATETIME; Source := STRSUBSTNO('%1 %2', "Modified By","Modified Date");
"Modified By" = DYNMICSUSR21
"Modified Date" = 19/01/12 09.01 33PM
Source = DYNMICSUSR21 19/01/12 09.01 33PM
HTH
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 -
hi david,
The original data (userid + CurrentDateTime) was in source field, i would like to copy them to modified by & modified date respectively.0 -
This should work for both examples, put it in a function add some tests and error messages if required
Variables:
TempSource - Code - 50
ToDate - Date
ToTime - Time//EVALUATE(Source,'dynmicsusr21 19/01/12 0901 33PM'); //Normalize the data remove the spaces, periods and colons in variable TempSource TempSource := DELCHR(Source); //This removes all spaces TempSource := DELCHR(TempSource,'=','.:'); //This removes : and . //28 Character variable left DYNMICSUSR2119/01/12090133PM //First 12 Characters are the USERID "Modified By" := COPYSTR(TempSource,1,12); //Trim the variable TempSource := COPYSTR(TempSource,13); //Extract the date to a variable EVALUATE(ToDate,COPYSTR(TempSource,1,8)); //Trim the variable TempSource := COPYSTR(TempSource,9); //Evaluate the time 090133PM becomes 21:01:33 EVALUATE(ToTime,TempSource); //User the Variables to create the Date Time Stamp "Modified Date" := CREATEDATETIME(ToDate,ToTime); //MESSAGE('%1 %2',"Modified By","Modified Date");
Stripped down VersionTempSource := DELCHR(Source); TempSource := DELCHR(TempSource,'=','.:'); "Modified By" := COPYSTR(TempSource,1,12); EVALUATE(ToDate,COPYSTR(TempSource,13,8)); EVALUATE(ToTime,COPYSTR(TempSource,21)); "Modified Date" := CREATEDATETIME(ToDate,ToTime);
HTH
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
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