How to reflect RITM state field values to SCTASK state field values

mania
Tera Contributor

Hi,

 

Reflect SCTASK state field values to RITM state field values. it is working but How to do for RITM to SCTASK.

Can anyone please help on this. It will be helpfull.

After/update:

mania_0-1716983164866.png

Thanks!

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @mania ,

I tried your problem in my PDI please make some changes this will work for you.

1. Create before BR. It so not recommended to use current.update() in after BR

2. Create BR on sc_req_item table 

3. Add below code 

 

 

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

	// Add your code here
	gs.log("Here id = " + current.sys_id);
	var gr = new GlideRecord('sc_task');
	gr.addQuery('request_item', current.sys_id);
	gr.query();
	while(gr.next()){
		gs.log('Inside while 123 = ' + gr.state);
		gr.setValue('state', current.state);
		gr.update()
	}

})(current, previous);

 

SarthakKashyap_0-1716984505009.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

 

View solution in original post

1 REPLY 1

Community Alums
Not applicable

Hi @mania ,

I tried your problem in my PDI please make some changes this will work for you.

1. Create before BR. It so not recommended to use current.update() in after BR

2. Create BR on sc_req_item table 

3. Add below code 

 

 

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

	// Add your code here
	gs.log("Here id = " + current.sys_id);
	var gr = new GlideRecord('sc_task');
	gr.addQuery('request_item', current.sys_id);
	gr.query();
	while(gr.next()){
		gs.log('Inside while 123 = ' + gr.state);
		gr.setValue('state', current.state);
		gr.update()
	}

})(current, previous);

 

SarthakKashyap_0-1716984505009.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak