How to get multi-line text g_form variable values from catalog item to workflow script?

bbf3562
Kilo Guru

In fulfiller workflow script, I am getting a multi text variable called get_name that array is assigned to in catalog client script. Here is what multi text variable looks like,

textarea.png

After submitted, In workflow script, gs.log(getList); is showing exactly log result as multi text box above,

log.png

However it seem when I try to use var lines = getList.split(','); to split members using comma and test it using log again but it not printing anything and sometime I get undefined. What is wrong with my code? Why getList is able to get string values but not lines variable? Here my sample codes,

find_real_file.png

1 ACCEPTED SOLUTION

Hi Bradley,



Can you try toString() and give it a try?


var lines = getList.toString().split(',');



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Bradley,



Can you share the log which is getting printed with Member is.


your code seems to be correct may be once you share the logs more can be inspected.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

I set up gs.log("Member is " + lines); before FOR loop, it show undefined result,


undefined1.png


I also tried gs.log("Member is " + lines[i]); inside the FOR loop, the log doesn't print anything. Same thing doesn't print after the FOR loop.


Hi Bradley,



Can you try toString() and give it a try?


var lines = getList.toString().split(',');



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

It working! I didn't know it need to have toString() as I thought it was already a string values. Thanks!