Autopopulate fields from RITM to SC Task when SC task is created by clicking new button from RITM

Teja7
Mega Contributor

 

Hi,

How to Autopopulate fields from RITM to SC Task when SC task is created by clicking new button under RITM Related lists.

 

Any help is appreciated.

 

thanks

teja

1 ACCEPTED SOLUTION

Hi,

 

It should happen automatically. Few things to validate before we write any scripts:

 

  • Kindly validate if Variable Editor is added to your Catalog Task form.
  • If it is added then Navigate to the Workflow which is getting attached to this Requested Item and then select the Workflow activity where this task is getting created and add the variables to the Right column as shown below:

find_real_file.png

 

And in case even if this does not works then what you need to do is "There  is a global Checkbox" listed on the variable form page, mark the chekcbox as "True" for all the variables you want to show on the Catalog task form when you click on the New button. Below is a screenshot for the same:

 

find_real_file.png

 

By Default on new instances This "Global" field is not available on the form layout, so you need to add it to your Variable Form layout and then  mark it as true.

I have tested this on my personal instance and it works. Let me know if you are facing any issue further.

 

 

Hope this help. Please mark the answer as helpful/correct based on impact.

 

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

4 REPLIES 4

shloke04
Kilo Patron

Hi,

 

There are multiple ways of doing so. t depends on your requirement. Say for example if you need to copy values when the New Button present in the related list is clicked then you can write an Display Business Rule on Catalog Task table and use the script mentioned below: 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	
	var ritm = new GlideRecord('sc_req_item');
	ritm.addQuery('sys_id',current.request_item);
	ritm.query();
	while(ritm.next()){
		current.short_description = ritm.short_description;  //Copying Short Description from RITM to catalog Task
		
	}

})(current, previous);

 

 

But in case you need in a scenario when some values are updated in Requested Item and then you need to copy it in Catalog Task then the script would almost be same written on Catalog task table only but type of BR would be either after/before based n your requirement and you need to use current.update() function in your script to update the values in Catalog Task table as shown below:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	
	var ritm = new GlideRecord('sc_req_item');
	ritm.addQuery('sys_id',current.request_item);
	ritm.query();
	while(ritm.next()){
		current.short_description = ritm.short_description;
		current.update();
	}

})(current, previous);

 

Hope

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Teja7
Mega Contributor

Hi Shloke,

 

Thanks!! its working , but how to autopopulate varaible editor with all variables from RITM to New task when new button is clicked.

 

Thanks 

Teja

 

Hi,

 

It should happen automatically. Few things to validate before we write any scripts:

 

  • Kindly validate if Variable Editor is added to your Catalog Task form.
  • If it is added then Navigate to the Workflow which is getting attached to this Requested Item and then select the Workflow activity where this task is getting created and add the variables to the Right column as shown below:

find_real_file.png

 

And in case even if this does not works then what you need to do is "There  is a global Checkbox" listed on the variable form page, mark the chekcbox as "True" for all the variables you want to show on the Catalog task form when you click on the New button. Below is a screenshot for the same:

 

find_real_file.png

 

By Default on new instances This "Global" field is not available on the form layout, so you need to add it to your Variable Form layout and then  mark it as true.

I have tested this on my personal instance and it works. Let me know if you are facing any issue further.

 

 

Hope this help. Please mark the answer as helpful/correct based on impact.

 

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Jaspal Singh
Mega Patron
Mega Patron

Hi Teja,

 

An OnLoad Client script that runs on catalog task table as below would help.

function onLoad() {
   //Type appropriate comment here, and begin script below

var parentis=g_form.getReference('requested_item',setvaluesfor);
alert('Parent RITM is '+parentis);

function setvaluesfor(parentis)
{
g_form.setValue('description',parentis.description);
//similarly you can use //g_form.setValue('field_name_on_Catalogtask_table',parentis.field_name_from_ritmtable)}
   
}

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.