How to convert 'domain\FirstName.LastName' into 'FirstName LastName' using string functions - report

DoddersAnton
Member Posts: 3
Hi,
I'm currently creating a document report for purchase orders. I'm specifically working on the word document template to populate the body of the email, I need to convert the created by field into a full name. (Purchaser name is not available).
I need to convert 'xxx\FirstName.LastName' into 'FirstName LastName'.
To do this in report builder, I used a combination of inst(), left/right & len functions:
However, I'll need to do this on the query side for it to create the full name I need in the word document. The below code is as far as I've got, I think I can remove the domain element but I'm not sure how to replace the '.' with a space.
I'm new to creating reports in Navision Dynamics and would greatly appreciate any guidance.
Many thanks,
A
I'm currently creating a document report for purchase orders. I'm specifically working on the word document template to populate the body of the email, I need to convert the created by field into a full name. (Purchaser name is not available).
I need to convert 'xxx\FirstName.LastName' into 'FirstName LastName'.
To do this in report builder, I used a combination of inst(), left/right & len functions:
=LEFT(RIGHT(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1), LEN(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1)) - 5),1) & LCASE(RIGHT(RIGHT(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1),LEN(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1)) - 5), LEN(RIGHT(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1), LEN(left(Fields!Createdby.Value, instr(Fields!Createdby.Value,".")-1)) - 5)) -1)) & " " & Left(Right(Fields!Createdby.Value, len(Fields!Createdby.Value) - instr(Fields!Createdby.Value,".")),1) & Lcase(RIGHT(Right(Fields!Createdby.Value, len(Fields!Createdby.Value) - instr(Fields!Createdby.Value,".")),LEN(Right(Fields!Createdby.Value, len(Fields!Createdby.Value) - instr(Fields!Createdby.Value,".")))-1))
However, I'll need to do this on the query side for it to create the full name I need in the word document. The below code is as far as I've got, I think I can remove the domain element but I'm not sure how to replace the '.' with a space.
COPYSTR("Purchase Header"."Created By User",5,STRLEN("Purchase Header"."Created By User"))
I'm new to creating reports in Navision Dynamics and would greatly appreciate any guidance.
Many thanks,
A
0
Best Answer
-
CONVERTSTR( COPYSTR("Created By User", STRPOS("Created By User", '\')+1), '.', ' ');
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035
Answers
-
CONVERTSTR( COPYSTR("Created By User", STRPOS("Created By User", '\')+1), '.', ' ');
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
Slawek_Guzek wrote: »
CONVERTSTR( COPYSTR("Created By User", STRPOS("Created By User", '\')+1), '.', ' ');
Thank you Slawek!
I then used your code to capitalise the first letter of the first name & last nameCreatedByUserName := CONVERTSTR(COPYSTR("Created By User", STRPOS("Created By User", '\')+1),'.', ' ');
CreatedByUserName2 := COPYSTR(CreatedByUserName,1,1) + LOWERCASE(COPYSTR(CreatedByUserName,2,STRPOS(CreatedByUserName,' ')-1)) + COPYSTR(CreatedByUserName,STRPOS(CreatedByUserName,' ')+1,1) + LOWERCASE(COPYSTR(CreatedByUserName,STRPOS(CreatedByUserName,' ')+2,STRLEN(CreatedByUserName)));
0
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