Business rule to set a field value

Appu
Tera Guru

Hi All 

I have a requirement that says whenever the "Service Type" field on the service offering table(child table) is inserted or updated.

on the parent table called "Business Service " the "Service Type" field should be updated with the same as the child table's "service type" value

 

Can someone provide me a solution..???

Thanks

1 ACCEPTED SOLUTION

Dot walk and update doesn't work, you have to GlideRecord to parent record and update it.

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

    var servicetype = current.getValue('u_service_type'); 
    
    if (JSUtil.notNil(current.parent)){
var gr = new GlideREcord('<parent table>');/add the table name here
	gr.addQuery('sys_id',current.parent )	
        gr.query();
if(gr.next())
{
gr.u_service_type = servicetype;
		gr.update();

	}

})(current, previous);

 

The condition of the BR should be that current.parent is not empty AND current.u_service_type Changes

-Anurag

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can easily achieve this using flow designer with no script.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am new to flow designer I haven't tried it so far. but I have heard that it reduces the effort of scripting.

Thanks for the suggestion