- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 10:52 AM
Hi Community,
I have a question regarding the use of scripts in Flow Designer. I have a script that creates and updates an incoming email into a incident ticket. The last part of the flow I have added an update action for the incident with correlation ID so that when a supplier sends their correlation id in the email subject line this populates the correlation id field in servicenow ticket and I need to write a one line script using the f(x) box.
So far I am able to pull the entire subject line into the correlation box, but I only need the number,
Appreciated your assistance
Many thanks
Steve
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 09:38 PM
Hi
Below, I just created a test-flow, which adds the String "OK" to the field "Info" and writes it back to the field "Info2". Same way you can do with the "substring" to cut out the right-most characters from my answer above.
Note, that my example is NOT on an "inbound mail action", but let me know if you can sort out the problem.
Let me know if that answers your question and mark my answer as correct and helpful.
BR
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 11:17 AM
Hi
You can get the last characters of a String by using
var str = 'Hello World';
gs.info(str.substr(str.length-5,str.length));
This will give you "World", so if you know the number of digits, that your Correlation ID Value will have, just put that number of characters in the function above, instead of "5".
Try this out in "Scripts - Background", and then adapt to your Flow Designer Script.
Let me know if that answers your question and mark my answer as correct and helpful.
BR
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 02:08 PM
Dirk,
Thank you for the response, its the script I seem to have a problem with in getting this to work.
Kind regards
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 09:34 PM
Hi
Did you make sure, that your script must RETURN a value?
You need to:
var correlation_id = '23456789'; // Or whatever you will calculate
return correlation_id;
If you do not return your variable, it will not work.
Give that a show
Let me know if that answers your question and mark my answer as correct and helpful.
BR
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 09:38 PM
Hi
Below, I just created a test-flow, which adds the String "OK" to the field "Info" and writes it back to the field "Info2". Same way you can do with the "substring" to cut out the right-most characters from my answer above.
Note, that my example is NOT on an "inbound mail action", but let me know if you can sort out the problem.
Let me know if that answers your question and mark my answer as correct and helpful.
BR
Dirk