How to set multiple variable values in a single variable using Run Script(workflow)

Anusha25
Tera Contributor

After creating Request, few variables like,

variable 1 : A 
                  B
                  C
                  D

variable 2: A1
                  B1
                  C1

variable 3:A2
                 B2
                 C2 etc

In Variable 4(multiple line text)the above 3 variable values should populate  with semicolon and space for each value.

29 REPLIES 29

Hi ,i want to populate multiple variable values into one variable  and each value should be populated with semicolon and space.

Abhijit4
Mega Sage

Hi,

Answer mentioned by Rohila should work, could you please share your script and output with more details so that we can help you further.

Thanks and Regards

Abhijit

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

Murthy Ch
Giga Sage

Hi Anusha,

Add getDisplayValue() and check.

Tested in BG script:

var gr=new GlideRecord("sc_req_item");
gr.addQuery("sys_id","7a5e0bef1b59cd10558d639bbc4bcb75");
gr.query();
if(gr.next())
{
gs.info(gr.variables.select_any_one.getDisplayValue());
}

Variable value in RITM:

find_real_file.png

O/p I got:

find_real_file.png

Hope it helps

 

Thanks

Murthy

Thanks,
Murthy

Hi murthy, 

need to populate multiple variable values into one variable with semicolon for each value .

Hi Murthy ,

the ouput  need to get in a single line with semicolon ?

please see the below attachment for reference 

find_real_file.png