How to split string in flow designer?

nayanmule
Tera Expert

Hi All,

I want to get values from one field in change request & populate it in another field on a change task form.

for eg. if I have a Change Plan field which has following values - 

newservername = testt123
oldservername = test256
cutoverdate = 03/23/2025
plantname = US
plantid = 1356.

 

I want to populate these values in change task description .

for eg. Change task - Update the 'newservername' to 'oldservername'.

 

I have multiple change tasks created through flow designer. I would like to know how can I split the string and use the values in change tasks or anywhere I need in flow designer.

 

Thankyou!

1 ACCEPTED SOLUTION

nayanmule
Tera Expert

Thankyou everyone for your responses. 

I have achieved it by creating an action. Within an action, I have added a script using inputs and outputs.

(function execute(inputs, outputs) {
// ... code ...
var data = inputs.inputString;
var lines = data.split('\n');   // this will split the string based on lines
var values = [];

for(var i=0;i<lines.length;i++){
    var parts = lines[i].split('=');    //this will split the string one more time using =
    if(parts.length  === 2){

        values.push(parts[1].trim());   //trim the second value string to remove unwanted spaces.
     
    }
}
 
outputs.newservername = values[0];
outputs.oldservername = values[1];
outputs.cutoverdate = values[2];

View solution in original post

6 REPLIES 6

Mark Manders
Mega Patron

Check this email parser action from the Share: https://developer.servicenow.com/connect.do#!/share/contents/8408077_parse_email_flow_action?v=2.5&t...

 

It is created to do the same from inbound emails (see this video for a great explanation on how it works: https://www.youtube.com/watch?v=uLHCw2GA3lo) but if you change it a bit to make the input your text field and within the script ensure you use the correct delimiter, it should work. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
Catalog Items are just a way to define inputs and launch flow. There are many reasons why the catalyst may be email. STEP BY STEP - Create the Catalog Flow as if you assumed form entry. - Create a new Flow Action to parse an email body for name:value pairs (OR download from share) - Create a ...

sohail_mohamad
Tera Expert

Hi @nayanmule,
You can use Flow variable of type String and Get the value of Change Plan field, then you can perform string operations. You will able to use this Description string inside the flow variable to any change tasks description or anywhere you need in flow designer.

Please mark any helpful or correct solutions as such. That helps others find their solutions.

Best regards,
Sohail

Ankur Bawiskar
Tera Patron
Tera Patron

@nayanmule 

when you create change tasks in flow you can use inline f(x) script and handle the string manipulation and return the value to be set

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@nayanmule 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader