- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 11:48 AM
Hi,
How can I pull location name (after location: ) from email subject line. whenever email receives using this subject line, I want to pull location and parse to location field (reference field) on catalog item.
Email Subject Line: Job Summary Report, location: United States ,Daily - RNOD-FILE-01
var gr = email.subject.toString().split('location: ');
var gr2 = gr[1];
gs.log(" ***Reddy: gr: " + gr);
gs.log(" ***Reddy: gr2: " + gr2);
I am using gr[1] which is pulling job summary report,
Please help!
Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 12:30 PM
Hi,
There's a few ways to do this, but to just keep going with what you have, you can use:
var gr2 = gr[1].split(',')[0];
For this reference field, keep in mind that that field expect a sys_id, so you'd either need to use a GldieRecord and then query to find the sys_id using the name from the parse you did here or...be confident enough to set the display value of that reference field using the name (I'd recommend looking it up instead).
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 12:30 PM
Hi,
There's a few ways to do this, but to just keep going with what you have, you can use:
var gr2 = gr[1].split(',')[0];
For this reference field, keep in mind that that field expect a sys_id, so you'd either need to use a GldieRecord and then query to find the sys_id using the name from the parse you did here or...be confident enough to set the display value of that reference field using the name (I'd recommend looking it up instead).
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 12:45 PM
If the format will always be the same you can try below.
var gr = 'Job Summary Report, location: United States ,Daily - RNOD-FILE-01';
var gr2 = gr.split('location:')[1]; //gets text after location:
var gr3=gr2.split(',')[0]; //gets text before ,Daily
gs.print(" ***Reddy: gr: " + gr);
gs.print(" ***Reddy: gr2: " + gr2);
gs.print(" ***Reddy: gr2: " + gr3);