- 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-16-2024 07:35 PM
Hi @Hervi
If I grasp it correctly, we have a form, and upon submission, we intend to insert the chosen data into a designated table. This way, these new records can be showcased in the related list of the change request form.
Could you share a screenshot of the form and the related list where you want to incorporate the data?
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 06:40 AM - edited 01-22-2024 12:14 AM
@Ankur Bawiskar Can you check this script -
var answer = [];
var change = current.variables.change_request_number;
var listvalues = current.variables.parent.toString();
var listArr = listvalues.split(',');
for (var i = 0; i < listArr.length; i++) {
var relatedListGR = new GlideRecord('task_rel_task');
relatedListGR.addQuery('child', change);
relatedListGR.query();
while (relatedListGR.next()) {
answer.push(relatedListGR.parent.getDisplayValue().toString());
relatedListGR.setValue('short_description', 'hi');
relatedListGR.setValue('priority', 3);
}
}
gs.info('Answer array is: ' + answer);
its showing me error as parent and child is undefined. My list collector field is parent and i am trying to push the selected values to reference field named parent on task_rel_task table. please guide.
- 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-22-2024 11:59 PM
This is not creating record . Also, its just redirecting me to form view of that table.