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

Anurag Tripathi
Mega Patron

Hi,

Try this

 

(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())
{
if(gr.skills == '')
{
gr.skills = current.skill;
}
else
{
gr.skills = gr.skills + ',' + current.skill;
}
gr.update();
}

})(current, previous);
-Anurag

Hi Anurag,

Thanks!! for responding 

I have tried your code after/before update but it's not working skill field still showing empty

any thing needs to change ?

Thanks,

Harikrishna 

what is the field name, skill or skills, 

some place its skill and some place in the code its skills. Fix that.

-Anurag

The field on the Case form is 'skills' and in the related list table Task Skill [task_m2m_skill]

is 'Skill'