After Business Rule Issue incident creates a problem

Community Alums
Not applicable

Hi,

My requirement is to create a problem through an incident when the user changes the incident state to onHold. It is not creating any problem record at all. Kindly help.

 

1.png

 

2.png

 

(function executeRule(current, previous /*null when async*/) {

	var gr = new GlideRecord('problem');
	gr.initialize();
	gr.short_description = 'After Business Rule';
	gr.description = 'After Business Rule';
	gr.first_reported_by_task = '9d3c1197c611228701cd1d94bc32d76d';
	gr.insert();
	gs.addInfoMessage('The problem created is ' + gr.number);
	action.setRedirectURL(current);

})(current, previous);

 

Regards

Suman P.

9 REPLIES 9

Anurag Tripathi
Mega Patron
Mega Patron

Check if there are any mandatory fields on Problem , that you are not entering in your script.

-Anurag

Uncle Rob
Kilo Patron

This seems like a great use case for a simple Flow with zero code.  Eliminate code as the point of failure alltogether.

PrashantLearnIT
Giga Sage

Hi @Community Alums 

 

Did you check for existing mandatory fields for problem table?

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Mark Manders
Mega Patron

What kind of process is this? An incident is set to On Hold and that creates a problem? That's very weird logic and I would first challenge this requirement before spending any more time on this. 

 

But that being said: I just copied your code into my PDI (OOB ITSM processes) and it immediately created a Problem. 
Check your logs to see what is happening. Check the problem logic to see if there is something blocking problems from being created (like a mandatory field that needs to be filled, or it aborts the creation). OOB your code works fine, so it must be something custom in your instance that is blocking it.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark