Creating Multiple RITMs from one RITM in Workflow - Trouble setting variables

Brian Bouchard
Mega Sage

Working through an issue with a workflow where I have 1 RITM that has a list of access level requests in a list collector. I've assigned the list collector to a scratchpad array and I want to parse through that array to create a new RITM for each of the items in the array.  Here's my runscript:

for (var i = 1; i < workflow.scratchpad.access_list.length; i++) {

	gs.sleep(1000);
	gs.log('Assignment Access Level ' +workflow.scratchpad.access_list[i].toString(),workflow.scratchpad.wf_name);

	var ritm = new GlideRecord('sc_req_item');
	ritm.newRecord();
	ritm.request = current.request;
	ritm.cat_item = current.cat_item;
	ritm.due_date=current.due_date;
	ritm.variables.role_name=current.variables.role_name;
	ritm.variables.access_level = workflow.scratchpad.access_list[i];
	//ritm.variables.access_level="b0d67332e4c9e40006d80e38f69704df";
	ritm.setWorkflow(true);
	ritm.insert();
	gs.sleep(1000);
}

 

When the script runs, I get a log entry that reads:

Assignment Access Level b0d67332e4c9e40006d80e38f69704df

But when the new RITM is created, the access_level variable is blank.  I was expecting the line:

ritm.variables.access_level = workflow.scratchpad.access_list[i].toString();

to properly set the access_level variable (a list collector) in the new RITM, but it is not.

 

Likewise, the line: ritm.variables.role_name = current.variables.role_name 

is not properly setting the new RITM's role_name variable.

 

What am I missing here?

23 REPLIES 23

Omkar Mone
Mega Sage

Hi 

try setting the ritm.setWorkflow(true); to ritm.setWorkflow(false); 

 

 

That does not seem to have an effect.

Hi 

Are those variables global ticked?

They were not. I tried setting that property and it did not seem to help.