- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016 09:15 AM
I'm trying to create a HR case from a UI Action on the Call module.
I'm using the OOTB UI Action and modify it to create a HR Case instead of an Incident, the HR Case isn't created though for some reason.
I've tried doing it with a background script and get the same result
Trying to create a HR Case doesn't work, nothing is created but a number is consumed in the number serie.
var gr = new GlideRecord('hr_case');
gr.newRecord();
gr.short_description = 'TEST';
gr.insert();
If I try doing the same for Incident or Finance Request it works fine and record is created.
var gr = new GlideRecord('incident');
gr.newRecord();
gr.short_description = 'TEST';
gr.insert();
Any idea why a HR Case isn't created?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016 11:43 AM
I just tried from Call module and it did create a HR case, but only if I wrap it in a function:
(function(current, previous, gs, action) {
var gr = new GlideRecord('hr_case');
gr.newRecord();
gr.short_description = 'TEST';
//gr.opened_for = gs.getUserID();
gr.opened_for = current.caller;
gr.insert();
})(current, previous, gs, action);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2016 11:43 AM
I just tried from Call module and it did create a HR case, but only if I wrap it in a function:
(function(current, previous, gs, action) {
var gr = new GlideRecord('hr_case');
gr.newRecord();
gr.short_description = 'TEST';
//gr.opened_for = gs.getUserID();
gr.opened_for = current.caller;
gr.insert();
})(current, previous, gs, action);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 12:48 AM
I can verify what Michael.Fry say - also when executed from a Background Script.
If I wrap the code in a function, then the HR Case is created - but without the function the record seems to be created (a sys_id is returned from the gr.insert() function) but it's not to be found anywhere (not even in the task table). I don't understand this behaviour rigth now (Helsinki Patch 3 Hotfix 7).
In the Background Script my wrapper function is simply:
(function() {
// My code
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 04:27 AM
It works when I wrap it into a function, no idea why it doesn't work without it when you can create Finance, Incidents, Changes and other type of records without wrapping it into a function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 05:08 AM
I had tried changing the order to a higher number, thinking something was causing conflict preventing hr case from being created, but that didn't work either. Not sure why must be in function at this point.