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 05:51 AM
yes Murthy , all variables are multi line text.
and all variables values are not setting at a time , based on environment variable (type of environment variable was list collector)
when we select environment choice either it should be uat or dev or prod or sit etc or i can select all choices at a time
and other 3 variables are populate based on role (type of role was reference)
when those multi line variables visible those values should populate in ad_group in a singe line with semicolon separated and space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2022 05:25 AM
Hi Murthy, 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-08-2022 05:14 AM
Hi Anusha,
I can see only two variables data in your screenshot, could you please show all variable data and paste your updated script as well so that we could help you further.
Thanks and Regard,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 05:52 AM
yes Abhijit, based on condition those variable will populate , which variable can see on the RITM that values should populate in ad_group variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 06:08 AM
ok so other variables which are not visible on the form might not have any values that is the reason it is adding undefined.
so while concatenating, you will have to add one more condition as below to validate if that values is not undefined
if(JSUtil.notNil(a)){
current.variables.ad_groups=current.variables.ad_groups+a;
}
if(JSUtil.notNil(b)){
current.variables.ad_groups=current.variables.ad_groups+b;
}
.
.
.
..
if(JSUtil.notNil(g)){
current.variables.ad_groups=current.variables.ad_groups+g;
}
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP