How to clean-up Multi-row variables in flow designer when displaying in description field?

Shawn1
Tera Expert

I have a flow created and I can get all the data in the description field but it is UGLY!

 

Shawn1_0-1696376438379.png

 

I need a way to remove all those extra characters.

 

Any suggestions?

Thank you

 

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Shawn1 

As MRVS value is a stringified version of JSON object, what you can do is create a flow variable and store this value after replacing all the characters with the help of replaceAll string method in inline script.

Then you can use the flow variable to append to your description.

 

 

var str = fd_data._1__get_catalog_variables.storage; // Change this to your Get Catalog Variables step and the MRVS variable name
str = JSON.stringify(str);
str = str.replaceAll("[", "").replaceAll("{", "").replaceAll("}", "----").replaceAll("]", "").replaceAll('"',"");
return str;

 

AnveshKumarM_0-1696388278003.png

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

View solution in original post

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

Hi @Shawn1 

As MRVS value is a stringified version of JSON object, what you can do is create a flow variable and store this value after replacing all the characters with the help of replaceAll string method in inline script.

Then you can use the flow variable to append to your description.

 

 

var str = fd_data._1__get_catalog_variables.storage; // Change this to your Get Catalog Variables step and the MRVS variable name
str = JSON.stringify(str);
str = str.replaceAll("[", "").replaceAll("{", "").replaceAll("}", "----").replaceAll("]", "").replaceAll('"',"");
return str;

 

AnveshKumarM_0-1696388278003.png

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

ChrisBurks
Mega Sage

Not being able to see the whole thing and just the stringified output, I would take a stab at using a regular expression to remove the undesired characters before assigning it to the description field.

function replacer(keytext) {
    if(keytext == ":")
         return " : ";
    else
         return "";
}
//assuming the variable holding the data was an JSON object or array of objects
var obj = [{
 "item_description":"Printer",
 "item_type":"other",
 "justification":"I need to print stuff",
 "quantity":"1"
},{
 "item_description": "",
 "item_type":"laptop",
 "justification":"need to compute",
 "quantity":"1"
}];

//Stringify it by wrapping it using method from JSON and replace the unwanted characters using .replace string method and regex
...
gr.description = JSON.stringify(obj)..replace(/[\[\{\}\]":]/g, replacer ).split(",").join("\n");

/****output
item_description : Printer
item_type : other
justification : I need to print stuff
quantity : 1
item_description : 
item_type : laptop
justification : need to compute
quantity : 1
*****/