Copystr and strlen functions

owiccrossett
Member Posts: 13
Hi,
I am in a report and i am trying to write some code in the "source expression" field. what I am attempting to do is to show the last 4 characters of the given field, however when i have a field that does not have any characters it gives me a "less then 0" error.
This is the function that i have come up with:
COPYSTR(PayCheckBuffer[RightSide]."Payroll Control Name",STRLEN(PayCheckBuffer[RightSide]."Payroll Control Name")-3,4)
so how do i write this script so that it only returns the last four characters if there is a value in the field?
thanks a ton,
chris
I am in a report and i am trying to write some code in the "source expression" field. what I am attempting to do is to show the last 4 characters of the given field, however when i have a field that does not have any characters it gives me a "less then 0" error.
This is the function that i have come up with:
COPYSTR(PayCheckBuffer[RightSide]."Payroll Control Name",STRLEN(PayCheckBuffer[RightSide]."Payroll Control Name")-3,4)
so how do i write this script so that it only returns the last four characters if there is a value in the field?
thanks a ton,
chris
0
Comments
-
1)a few questions first is "Payroll Control Name" always the same # of characters Except when it's blank?
2)Is It normal to be blank?
3) Make a Variable varPayContolName
Do something like
IF (STRLEN("Payroll Account Name") > 3)
then
VarPayControlName := varPayControlName:= COPYSTR("Payroll Control Name",((STRLEN("Payroll Control Name"))-3),4)
Else
VarPayControlName := 'Oops'; //Whatever you want to do if it's blank
varPayControlName will then be the sourceExp Field.0 -
Just a little note:
When you are selection from a point to the end of a string you do not need to specify the length.
so you can leave out the ,4 and the()
COPYSTR("Payroll Control Name",STRLEN("Payroll Control Name")-3)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
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