How to update form field value based on the related list record field value by using Business rule

Hari16
Tera Contributor

Hi Community,

I have a requirement to update skill field on the case form when ever the Task skills related list is updated with a skill

find_real_file.png

find_real_file.png

I have written before insert Business rule but it's not working

(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("sn_customerservice_case");
gr.addQuery('sys_id',current.skill);
gr.query();
while(gr.next())
{
gr.skills = current.skill;
gr.update();
}

})(current, previous);

Can any one have any  better idea ?

Thanks,

Harikrishna 

15 REPLIES 15

Hari16
Tera Contributor

Hi Shloke,

Please find this 

find_real_file.png

 

find_real_file.png

and the result is below task skill is not reflecting into the skills field on the form 

find_real_file.png

find_real_file.png

Thanks, 

Hari

Okay. Just need to update Line number 7 of your code as below:

gr.skills = gr.skills + ',' + current.skill;

Rest all looks okay . Please try this and let me know for further issues.

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

Regards,
Shloke

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

Regards,
Shloke

Hari16
Tera Contributor

Hi shloke,

Thanks!! for your valuable time 

Still it's not updating 

find_real_file.png 

Hi,

Are you referring to the correct field when you are trying to do an addQuerym in your script above.

Please make sure you refer the correct field (i.e. field present on child Table which is referring to parent Table)in line below 

I see you have used Skills in your addQuery and then again in line number 7. Are both the fields same in your case?

This is my script which is working when I am updating watch list from Incident task to Incident:

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

// Add your code here
var gr = new GlideRecord('incident'); // Replace your Parent table Name here
gr.addQuery('sys_id',current.incident); // Replace Incident with the Field which is connecting both tables
gr.query();
if(gr.next()){
gr.watch_list = gr.watch_list + ',' + current.watch_list;
gr.update();
}


})(current, previous);

 

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

Regards,
Shloke

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

Regards,
Shloke

Say For example, Below is my Incident task form screenshot where I have Incident field which is parent in my case so I have used Incident in Add Query so you need to check for your corresponding field in addQuery. Rest all code looks good to me:

find_real_file.png

Regards,
Shloke

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

Regards,
Shloke