Create an IT incident from the HR plugin

zwimi
Kilo Contributor

Hi all,

I have a problem with an HRC. In the following my example:

An employee creates a request and the responsible HR worker delegates it to IT department, because he can not resolve the issue.
The HR worker therefore wants to open a ticket at the IT servicedesk.

For clarification:
The HR instance and the IT instance should be strictly seperated.

Here are my Questions:

1. How can the HR worker pass the HRC to IT department ?(create an INC)

2. Can the newly created ticket be configured, so only information, which is not confidential, is visible?

Hopefully someone can Help.

1 ACCEPTED SOLUTION

It would look something more like this - ensure you have the Client checkbox checked and the onclick field says "runClientCode()" (without quotes)



//Client-side 'onclick' function


function runClientCode(){


    if(confirm(confirm("Do you want to create an incident") == false){


          return false;   //Abort submission


    }


    //Call the UI Action and skip the 'onclick' function


    gsftSubmit(null, g_form.getFormElement(), '<button_action_name>'); //MUST call the 'Action name' set in this UI Action


}



//Code that runs without 'onclick'


//Ensure call to server-side function with no browser errors


if(typeof window == 'undefined')


    runBusRuleCode();



//Server-side function


function runBusRuleCode(){


        var inc = new GlideRecord('incident');


          inc.initialize();


          inc.short_description = 'Test description';


          inc.caller_id.first_name = 'John';


          inc.caller_id.last_name = 'Smith';


          inc.insert();


}


View solution in original post

20 REPLIES 20

It will if you want it to. The example I provided does not. You would add a couple lines in the runBusRuleCode() section something like this:



function runBusRuleCode(){


        var inc = new GlideRecord('incident');


          inc.initialize();


          inc.short_description = 'Test description';


        inc.u_hrc = current.sys_id;


          inc.caller_id.first_name = 'John';


          inc.caller_id.last_name = 'Smith';


          inc.insert();



        current.state = 3; // Closed Complete


        current.update();


}



Update the field names accordingly and the state value as needed.


Thank you very much!


Hey Chuck, @ctomasi



I know this is a bit old - however I stumbled upon HR How-To: Transferring HR Cases to IT Incidents before venturing to yours here.



I created the new UI Action as information provided by both posts. I made my UI Action a Form Link - Once I click on it, I do receive the message making sure I want to close the current HR Case and create an Incident. I click on OK, and then my page refreshes to my last visited page (in my case, it reloads the List view of Cases assigned to me) (this is all in our test instance).



find_real_file.png



And here is my script: (again, same as link post provided)



//Client-side 'onclick' function


function runClientCode(){


if(confirm("Do you want to close this case and create an incident?") == false){


return false;   //Abort submission


}


//Call the UI Action and skip the 'onclick' function


gsftSubmit(null, g_form.getFormElement(), 'Transfer to IT'); //MUST call the Action name set in this UI Action


}




//Code that runs without 'onclick'


//Ensure call to server-side function with no browser errors


if(typeof window == 'undefined')


runBusRuleCode();




//Server-side function


function runBusRuleCode(){


var inc = new GlideRecord('incident');


inc.initialize();



// HR Case fields that will carry over to the IT Incident


inc.short_description = current.short_description;


inc.description = current.description;


inc.work_notes = 'Transferred from HR case ' + current.number;


inc.u_hrc = current.sys_id; //References HR Case from IT Incident form. Update with your custom Incident field or remove this line.


inc.caller_id = current.opened_for;


inc.insert();


var inc_num = inc.number;



current.state = 3; //Remove this line if you want to keep the HR case open


current.comments = 'This case has been closed and transfered to IT.   New incident number is ' + inc_num;


current.update();


}



*****************



Any idea as to why my page would just refresh back to my last visited page? I also go to my incident table and there are no incidents created.


Thanks in advance - I understand if figuring out my question is a bit on the tougher side - as I had thought it could be an issue to do how customized our instance can be.



Cheers,


-Rob


Hi Rob



Check the line below (towards the bottom of your code) to make sure you created the custom field on the incident table to link back to the original HR Case.   If you didn't, the code is likely failing and that's why you are seeing this behavior.



inc.u_hrc = current.sys_id; //References HR Case from IT Incident form. Update with your custom Incident field or remove this line.


Hey Kiel,


Thank you very much for your reply and suggestion. I tried commenting out that line for now to see if I can get it to work for the time being without that. But it still does the same thing. Going to try and figure out why a little later today. I have a co-worker who is an admin with me to our instances. They know more about code than I do currently.



Let me know if you have any other ideas I can work off of as well. Again, thank you for replying!



Cheers,


-Rob