- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2018 02:51 PM
How can I split the field name (User Table), into First Name and Last Name fields? I only have a space betweek the first and last name to identify where to split it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2018 03:13 PM
Hi Adri,
Use the string split method on "name" field in sys_user table.
Check this code
var name = "ABC XYZ";
var splitName = name.split(' '); // use space as a delimiter
gs.print('first name ->'+splitName[0]);
gs.print('last name ->'+splitName[1]);
Thanks,
Ashish
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2018 03:13 PM
Hi Adri,
Use the string split method on "name" field in sys_user table.
Check this code
var name = "ABC XYZ";
var splitName = name.split(' '); // use space as a delimiter
gs.print('first name ->'+splitName[0]);
gs.print('last name ->'+splitName[1]);
Thanks,
Ashish
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2021 11:04 AM
Hi Ashish,
could u pls help me on this:
In a string single field(Contact Name), we have the name "Priya Dubey"
now, this has to be print-like (pdubey) via email script.
Regards,
Priya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2021 11:17 AM
Hi
You can use below email script.
var name="Priya Dubey"
var trunName = name.substring(0, 1)+name.split(" ")[1];
template.print(trunName.toLowerCase());
Hope it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2018 03:43 PM
There are multiple string manipulation techniques in javascript which helps you to solve various types of issues like this.
Please refer to string methods in w3schools under javascript thread.
Once you use split method in string manipulations it will load the values into the array based on what ever delimiter you have mentioned.
For ex : name = adri,servicenow
name.split(",") ---> results in name = ["adri","servicenow"]
in the same way we can have any character as a delimiter.
Thanks,
Siva