Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Problem number not visible after incident record creation

Shubham_verma
Tera Contributor

Hi,

I want to create a business rule for when a incident record is created ,a problem record should also get created.

Its working fine ,but when I am trying to populate a message a new problem ticket is created,it is not showing problem record number.

(function executeRule(current,
_previous) {
var x = new GlideRecord('problem');
x.category = current.category;
x.short_description = current.short_description;
x.cmdb_ci = current.cmdb_ci;
gs.addInfoMessage("A problem ticket is created "+x.number);
x.insert();
})(current, previous)

2 ACCEPTED SOLUTIONS

Ashir Waheed
Kilo Sage

Hi @Shubham_verma ,

 

Modify your script accordingly, Problem number will be assigned after the record is created. You have to fetch the number later on.

 

var x = new GlideRecord('problem');
x.category = current.category;
x.short_description = current.short_description;
x.cmdb_ci = current.cmdb_ci;
x.insert();

gs.addInfoMessage("A problem ticket is created "+x.number.toString());

 

Hopefully this will resolve you issue.

 

Regards,

Ashir Waheed

 

View solution in original post

Sumanth16
Kilo Patron

Hi Shubham,

 

gs.addInfoMessage("A problem ticket is created "+x.number); line should be after insert function.  after inserting only problem number will appear in message.

 

Please mark it as helpful (or) correct if it helps.


Thanks & Regards,
Sumanth Meda

View solution in original post

4 REPLIES 4

Ashir Waheed
Kilo Sage

Hi @Shubham_verma ,

 

Modify your script accordingly, Problem number will be assigned after the record is created. You have to fetch the number later on.

 

var x = new GlideRecord('problem');
x.category = current.category;
x.short_description = current.short_description;
x.cmdb_ci = current.cmdb_ci;
x.insert();

gs.addInfoMessage("A problem ticket is created "+x.number.toString());

 

Hopefully this will resolve you issue.

 

Regards,

Ashir Waheed

 

it worked.Thanks

Sumanth16
Kilo Patron

Hi Shubham,

 

gs.addInfoMessage("A problem ticket is created "+x.number); line should be after insert function.  after inserting only problem number will appear in message.

 

Please mark it as helpful (or) correct if it helps.


Thanks & Regards,
Sumanth Meda

it worked.Thanks.