Create HR case from UI Action

palmen
Tera Guru

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?

1 ACCEPTED SOLUTION

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);


View solution in original post

8 REPLIES 8

Michael Fry1
Kilo Patron

It did not create the case until I add:


gr.opened_for = gs.getUserID();


Try adding that line and see what happens:


(function(current, previous, gs, action) {


     


      var gr = new GlideRecord('hr_case');


      gr.newRecord();


      gr.short_description = 'TEST';


      gr.opened_for = gs.getUserID();


      gr.insert();


})(current, previous, gs, action);


I get the same as before, no HR Case is created.



In my UI Action I had the following but without any luck


gr.opened_for = current.caller;


current.caller did not work but current.caller_id did work.



Did you clear all the HR cases that come out of the box? There are some with an updated date in the future, so my newly created cases are farther down in the list.


It's a brand new instance with no demo data so I have 0 HR Cases there.



The field name is caller in the call module so it should not be caller_id in our case.


I tried with gs.getUserID() in a backgroudn script and it's not working either.