Creating Array From Variables in Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 08:59 AM
Hello, I think this should be a fairly easy solve but I am currently stuck on how to dynamically create an array of all variable inputs from a form (I am looking to create a Business Rule to format non-blank variables and populate the Description field of RITMs on Insert).
I know how to access individual variables with current.variables.[var], but I'm not sure how to access the full set of variables to iterate through and dump them into an array without having to explicitly name each variable. Any advice appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 09:25 AM
There is no method to get all the variables at a time.
You have to use current.variables.[var] method.
You can add all the variables in an array and iterate through it, anyway it be will one time activity.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 11:08 AM
I'm also trying to do something similar. I want to create a loop to populate an array with list of variables:
[kit1,kit2,kit3........kit29,kit30]
//businessRule for insertion
var kits1to30 = [];
for (var z = 1; z<31; z++){
var currentKit = "current.kit"+z;
kits1to30.push(currentKit);
}
but I just get the string, not the current value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2021 11:36 AM
Does adding the "Variable Editor" to the form not fulfill your requirements instead of dumping everything into the Description field?
I usually setup my Requested Item form like this, with the "Variable Editor" on a "User Supplied Information" tab so it basically replicates the Catalog Item the user filled out: