Problem number not displayed

Community Alums
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
Mega 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
Mega 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.



Community Alums
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
Kilo Patron
Kilo 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

Ankur Bawiskar
Tera Patron
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader