Pass the value with "\n" in multiline variable if new line in flow action for integration

manish62
Tera Contributor

Hello Team,

 

I am working on one of the integration and user copy and paste some content generated in multiline variable in catalog form, Integration expectation that   when we send the payload then for each new line in multiline variable content remove new line and add \n like "test\ncopy\npaste".

 

Please let me know any solution for this.

 

Thanks,

Manish

2 REPLIES 2

manish62
Tera Contributor

Hello Team,

 

Could anyone put some light how to achieve this.

 

Thanks,

Manish

Murthy Ch
Giga Sage

Hello @manish62 

You can try the below approach in your flow:

var gr = new GlideRecord("incident");
gr.addQuery("sys_id", "b1827ade977e0e100077f43de053af02");
gr.query();
if (gr.next()) {
    var incDesc = gr.getValue("description").trim(); //remove any extra spaces at the start or at the end
}
gs.info(incDesc);
var newDesc = incDesc.replace(/\r?\n/g, "\\n");  //replace with \n
gs.info(newDesc);

(=tested)

Thanks,
Murthy