Need to update the related list on a change request form FROM catalog item list collector

Hervi
Tera Contributor

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 

@Anil Lande @Ankur Bawiskar 

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
   
}

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

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

View solution in original post

6 REPLIES 6

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);

 

Screenshot 2024-01-23 at 15.38.21.png

Timi_0-1705999177660.png

 

 

Cheers,

Tai Vu

Hervi
Tera Contributor

Thanks for the reply @Tai Vu . 'Relate SM records' is the related tab on change form.

Hervi_0-1705472447968.png

 

this is my catalog item.

 

Hervi_1-1705472560778.png