I have question on Incident Number is not populating on Request form

Community Alums
Not applicable

Hi There,

 

   I have one issue, when Incident is converted to Request at that time Incident number should auto populate on request form parent field, for this I have written one After (Insert/Update) Business Rule On Incident Table,

 And in Script logs also, I'm getting the proper Incident and Request Sysid's but on the Request form, parent field is not populating with the Incident number.

please find the below code 

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
var incNum = current.sys_id;
var ReqsysId = current.u_request;
gs.log('The Number of Incident is:' + incNum + " " + ReqsysId); 
}
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', ReqsysId);
req.query();
if (req.next()) {
gs.log('Checking');
req.parent = incNum;
gs.log('field check' + ' ' + req.parent)
gs.log('AAAAAAAA' + req.sys_id);
req.update();
}

PriyaSm_1-1681807822788.png

Can some one please help me to populate Incident Number on parent field,

 

Thanks,

 

 

12 REPLIES 12

@Community Alums 

why not to use the OOB Context menu?

It does the same thing

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

@Community Alums 

you are not querying properly

update as this

var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
	var incNum = current.sys_id;
	var ReqsysId = current.u_request; //here u_request field is present on Incident table, which stored Request No.
	gs.log('The Number of Incident is:' + incNum + "  " + ReqsysId);

	var req = new GlideRecord('sc_request');
	req.addQuery('sys_id', ReqsysId);
	req.query();
	if (req.next()) {
		gs.log('Checking');
		req.parent = incNum;
		gs.log('field check' + '  ' + req.parent);
		gs.log('AAAAAAAA' + req.sys_id);
		req.update();
	}
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Community Alums
Not applicable

 

I have tried the above but which is also not working.

req.addQuery('sys_id',ReqsysId);

 

This Query is not running,

All the logs after this line are not triggering.

Could you please help me where i need to change.

 

Thanks,

@Community Alums 

u_request holds sysId or REQ number?

if number then use this

req.addQuery('number', ReqsysId);

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

Community Alums
Not applicable

Tried this, but still not working.