How to set multiple variable values in a single variable using Run Script(workflow)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2022 02:52 AM
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.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 07:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 07:43 AM
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 05:25 AM
Hi Abhijit, In my scenario ,variable1+variable2+variable3+variable4+variable5 is my expectation ,in some cases variable2 and varaible4 may not be visible to user on request form so here the script is fetching the default value of variable2 and 3 which is wrong.
how to identify the hidden variables from the script .
Please suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 05:43 AM
There is no way to validate that in BR as far as I am aware of. However, we have it in client script as below.
g_form.isVisible
I suggest you to understand how your logic is implemented to show/hide fields, there must be something which is getting checked to show/hide fields. if so then you can use same parameters here while concatenating values.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 04:34 AM
Hi all, Due to default values in backend unable to achieve so cleared all values before submit and implemented the below script in workflow . It worked.
var a, b, c, d, e, f, g;
a = current.variables.active_directory_groups.getDisplayValue().toString().split("\n");
b = current.variables.active_directory_groups_sit_env.getDisplayValue().toString().split("\n");
c = current.variables.active_directory_groups_dev_env.getDisplayValue().toString().split("\n");
d = current.variables.modify_active_directory_groups.getDisplayValue().toString().split("\n");
e = current.variables.active_directory_groups_UAT.getDisplayValue().toString().split("\n");
f = current.variables.active_directory_groups_newordelete.getDisplayValue().toString().split("\n");
var str = '';
if(a!='')
str+= a+'; ';
if(b!='')
str += b+'; ';
if(c!='')
str += c+'; ';
if(d!='')
str += d+'; ';
if(e!='')
str += e+'; ';
if(f!='')
str += f+'; ';
current.variables.ad_groups=str;
Thank you all for support.