- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 05:58 AM - edited 01-19-2024 06:42 AM
Hi Community,
I am trying to update related list of change request form. Suppose there is a related list A - i want to add multiple records to it from my catalog item. How can i achieve this?
I am writing a catalog client script. I am storing the selected values of my list collector but after that i dont know how to copy those fields under one of the related list on my change_request form.
My catalog item also has a field of change number. so only for the selected change these selected choices will be pasted in the related tab of change
@Prateek kumar @Govind Kumar @Mohit Yadav @rohantyagi @vinothkumar @Adam Stout @gyedwab
Kindly guide.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var collectorName = 'parent';
var myListCollector = g_list.get(collectorName);
var selectedValues = myListCollector.selectedValues();
//Type appropriate comment here, and begin script below
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 07:17 PM - edited 01-23-2024 12:43 AM
Hi @Hervi
You can give the below script a try.
If you're using a Catalog item with some specific workflow, you can put it into the Script activity in your workflow. So after submission it will generate record to the Task Relationship table.
var changeSysID = current.variables.change_request_number.toString();
var parents = current.variables.parent.toString().split(',');
for (var i in parents){
var gr = new GlideRecord('task_rel_task');
gr.addQuery('child', changeSysID);
gr.addQuery('parent', parents[i]);
gr.addQuery('type', '<your_type_sys_id>'); //Store in the Task Relationship Type [task_rel_type] table
gr.query();
if(gr.hasNext()){
continue;
}
gr.initialize();
gr.setValue('child', changeSysID);
gr.setValue('parent', parents[i]);
gr.setValue('type', '<your_type_sys_id>');
gr.insert();
}
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 12:39 AM
Hi @Hervi
Oops I forgot you're using record producer, you can try the below one instead.
var changeSysID = producer.change_request_number.toString();
var parents = producer.parents.toString().split(',');
for (var i in parents){
var gr = new GlideRecord('task_rel_task');
gr.initialize();
gr.child = changeSysID;
gr.parent = parents[i];
gr.type = 'd798ba000a2581020048305ef5287403'; //your relationship type
gr.insert();
}
current.setAbortAction(true);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 10:22 PM
Thanks for the reply @Tai Vu . 'Relate SM records' is the related tab on change form.
this is my catalog item.