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 

any update on this?

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

Rahul Kumar17
Tera Guru

Hi Priya,,

 

To fix this, you can modify your code as follows:

 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('u_requestISNOTEMPTY');
gr.query();
if (gr.next()) {
var incNum = gr.sys_id; // get the sys_id value of the incident record
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; // set the parent field value to the incident sys_id
gs.log('field check' + ' ' + req.parent)
gs.log('AAAAAAAA' + req.sys_id);
req.update();
}

 

Thanks,

Rahul Kumar

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar

Community Alums
Not applicable

Hi @Rahul Kumar17 ,

Thanks for your response 

 

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,