We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

Thameem Ansari
Giga Guru

Hi Hari. I noticed that in your code

var gr = new GlideRecord("sn_customerservice_case");
gr.addQuery('sys_id',current.skill);
gr.query();
while(gr.next())
{
gr.skills = current.skill;
gr.update();
}

 

line number 2 you are using the wrong field in the query. as current.skill is sys_id of the skill record. 

You need to use current.task to get the case record. please update the query as follows

gr.addQuery('sys_id',current.task);

 

Please mark it as helpful/correct If my answer is helpful in any way, 

Best regards,

Thameem