Update the parent RITM work notes.

achacko
Kilo Guru

Hi All

For our on-boarding process we receive email from the HR with new employee details to ServiceNow; ServiceNow then creates a request to the helpdesk. From the RITM form, Helpdesk uses the UI action to create the new user in AD. By clicking the UI Action, it will open to a service catalog called 'create a user to AD' and the new user details will be auto populated to the RITM form. On submitting, the new user will be created in AD. 

I am able to bring the parent RITM number to the new request. I need help for updating the work notes of the parent RITM with the "Create new user in AD" request number or RITM number so the helpdesk will know for which request the new user was created.

1 ACCEPTED SOLUTION

achacko
Kilo Guru

I could achieve this by Business Script

Condition

Item is “Create a new user in AD”

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

               var req_num = current.request.getDisplayValue();

               var getInci = current.u_neo_reference_request.getRefRecord();

               getInci.work_notes = "Request "+req_num+" has been created for creating the new user on AD";

               getInci.update();

})(current, previous);

View solution in original post

4 REPLIES 4

Mike Patel
Tera Sage

Can you share your code that gives you RITM number

Step 1:  Created the reference field “reference request” on the service catalog.

Step 2: Created reference field “Neo Reference request” on the RITM form.

Step 3:  Used Catalog Client Script

function onLoad() {

var url = document.URL.parseQuery();

var sysID = getParameterValue17(url,'sysparm_sysid');

if(sysID)

               g_form.setValue('reference_request',sysID);

function getParameterValue17(url,sysID) {

               if (url[sysID]) {

                              return decodeURI(url[sysID]);

               } else {

                              return;

}

}

 

Step 4: Workflow

Added Run Script

current.u_neo_reference_request=current.variables.reference_request;

 

If this helped you please mark it useful

andrewdunn
Giga Expert

Hi - sorry that my coding is not good but I believe you can do the following

Create a business rule that identifies the fields have been changed - eg Login field changes from empty

parentitm.comments = current.variables.accountname;

 

The above logic is to

select the value from the parent field (ie the ticket)

Add to the comments section the value that is in the variable that has been updated

 

Below is the code to pass information from an RITM to a task. All you want to do is replace the sc_task table with the table name that your parent ticket sits in

 

var thisRITM = current.number;  //thisRITM is the one just commented 
var cc = current.work_notes; //get the current work notes before updated 
 
var ReqTask = new GlideRecord('sc_task');  //query for any tasks associated to thisRITM 
ReqTask.addQuery('request_item.number', thisRITM); 
ReqTask.query(); 
 
while (ReqTask.next()){ 
ReqTask.work_notes = thisRITM + " - Work Notes updated: \n" + cc; //update the comments into worknotes in the tasks with the comments from the RITM 
ReqTask.setWorkflow(false); 
ReqTask.update(); 

 

achacko
Kilo Guru

I could achieve this by Business Script

Condition

Item is “Create a new user in AD”

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

               var req_num = current.request.getDisplayValue();

               var getInci = current.u_neo_reference_request.getRefRecord();

               getInci.work_notes = "Request "+req_num+" has been created for creating the new user on AD";

               getInci.update();

})(current, previous);