- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 06:35 PM
Hi,
I am try to create a record in a m2m table based on a List Collector variable in a request item.
I have a workflow script that creates a record but only the first option in the list collector field is created. I need to create a separate record for each list collector option.
Workflow Script:
var BenRecord = new GlideRecord('u_m2m_bank_ops_requested_item');
BenRecord.initialize();
BenRecord.u_bank_ops_change_benefits_and_impact = current.variable_pool.benefit_of_change;
BenRecord.u_requested_item = current.number;
var sysId = BenRecord.insert();
Outcome:
Only the first option in the List Collector variable is created and it is created without a requested item number.
Any assistance is greatly appreciated.
Thanks
Monique
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 07:08 PM
This was the script that allowed me to create multiple entries based on a List Collector variable.
var benefit = String(current.variable_pool.benefit_of_change).split(",");
for(i = 0; i < benefit.length; i++){
var benefitrec = new GlideRecord('u_m2m_bank_ops_requested_item');
benefitrec.initialize();
benefitrec.u_requested_item = current.sys_id;
benefitrec.u_bank_ops_change_benefits_and_impact = benefit[i].trim();
benefitrec.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 06:53 PM
Hi, your reference to the task may need to be current.sys_id - number is just a field within the task record.
Have you undertaken any debugging\printed the values of current.whatever to screen or log?
This should be your first step in trying to resolve any issue of this type.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 06:54 PM
Hi
In the below line i think current.number is the Request number. Try current.sys_id instead of current.number
BenRecord.u_requested_item = current.number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2019 07:08 PM
This was the script that allowed me to create multiple entries based on a List Collector variable.
var benefit = String(current.variable_pool.benefit_of_change).split(",");
for(i = 0; i < benefit.length; i++){
var benefitrec = new GlideRecord('u_m2m_bank_ops_requested_item');
benefitrec.initialize();
benefitrec.u_requested_item = current.sys_id;
benefitrec.u_bank_ops_change_benefits_and_impact = benefit[i].trim();
benefitrec.insert();
}