Flow designer script to remove text from subject line leaving Correlation ID

SW7
Giga Guru

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 

 

1 ACCEPTED SOLUTION

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.

find_real_file.png

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

 

 

 

 

View solution in original post

12 REPLIES 12

DirkRedeker
Mega Sage

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

 

 

 

Dirk,

Thank you for the response, its the script I seem to have a problem with in getting this to work.

Kind regards

Steve

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

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.

find_real_file.png

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