Creating Array From Variables in Business Rule

Ryan Price
Kilo Contributor

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.

3 REPLIES 3

Pranesh072
Mega Sage
Mega Sage

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.

bevo
Tera Expert

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

Jim Coyne
Kilo Patron

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:

 

find_real_file.png