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

did you update the script with proper field name? is it working or not?
If not please add proper logs in the script to debug where its going and wlat values is it getting.

-Anurag

Hari Prakash Y2
Tera Contributor

Hi Hari,

You can also use after BR for this requirement. Please try using the same code posted by you ( remove update() ) or make use of anurag's code. it should work ideally.

 

Note: I see you are querying Single record in second line, while is also can be removed. Go with If directly.

 

Regards,

Hari

shloke04
Kilo Patron

Hi,

Please write a After Update Business Rule on your Child table i.e. Task Skills and put a condition as below:

Skills Changes

Script to be used here:

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

	// Add your code here
	
	var gr = new GlideRecord('Table Name'); // 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.Parent_FIELD = gr.Parent_FIELD + current.CHILD_FIELD;
		gr.update();
	}

})(current, previous);

find_real_file.png

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 shloke04,

Thanks!! for the response

I tried that but it is not working, the skills field on the case form is List collector type does this make any conflict?

 

Thanks,

Hari

 

It should not because I have tried it in my PDI with Watch List type field which is also a multi select field and works fine.

Can you share what you have configured as a Business Rule including the condition as well?

Regards,

Shloke

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

Regards,
Shloke