Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Problem number not displayed

Not applicable

Hi,

When I create a new incident , A problem record is also being created onafter business rule which is working fine.

Under info message , Problem number is not being displayed .

PS code below

 

 

(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);
1 ACCEPTED SOLUTION

Najmuddin Mohd
Giga Sage

Hi @Community Alums ,
You are missing, x.initialize(); and Info message should be after x.insert();

 

(function executeRule(current,        
 _previous) {
    var x = new GlideRecord('problem');
    x.initialize();
    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);
})(current, previous);

 


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.



View solution in original post

4 REPLIES 4

Najmuddin Mohd
Giga Sage

Hi @Community Alums ,
You are missing, x.initialize(); and Info message should be after x.insert();

 

(function executeRule(current,        
 _previous) {
    var x = new GlideRecord('problem');
    x.initialize();
    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);
})(current, previous);

 


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.



Not applicable

Its working fine .

Thanks.

gs.info wont work with async BR?

When I used same with async , gs.info is not working

Bhavya11
Mega Patron

hi @Community Alums ,

 

initialize();- missing in code. Please add it will 

 

(function executeRule(current,        
 _previous) {
    var x = new GlideRecord('problem');
    x.initialize();
    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);
})(current, previous);


 

Thanks,

BK


Regards
BK
LinkedIn: https://www.linkedin.com/in/bhavyashree-karanth-55032a121
YouTube: https://www.youtube.com/@NowWithBhavya

Ankur Bawiskar
Tera Patron

@Community Alums 

how did it work without initialize()?

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

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