How to set HR Service & COE on UI Page to Create Case (Kingston)

Dallas16
ServiceNow Employee
ServiceNow Employee

Hello,

I created some buttons on the Create HR Case Form, they call a function that I created to try and set the two values in COE and HR Service and then call the CreateCase() function after the two fields get set as would normally occur if someone selected the options and clicked create.

I'm doing something wrong with trying to set the value of the two reference fields as when it hits the create case function, an error is thrown "Failed to retrieve service"

 

$scope.setCOE = function() {

$j("#coe_input").select2("data", { display: 'HR Payroll Case', table: 'sn_hr_core_case_payroll' });
$j("#service_input").select2("data", { display: 'Payroll Discrepancy', table: 'sn_hr_core_case_payroll' });
return $scope.createCase();

};

1 ACCEPTED SOLUTION

_ _ _ _
ServiceNow Employee
ServiceNow Employee

It fails to retrieve the service because you did not set the sys_id for the #service_input option.

The values to set for the #service_input are sys_id, coe, display, template, parent, e.g.:

$j("#service_input").select2("data", { sys_id: 'SERVICE_SYS_ID', coe: 'sn_hr_core_case_payroll', display: 'Payroll Discrepancy', template: 'TEMPLATE_SYS_ID', parent: 'Topic Category Name' });

Note: There is extra logic on the page that you may be skipping by bypassing the normal route.

View solution in original post

4 REPLIES 4

Kiel Sanders
ServiceNow Employee
ServiceNow Employee

Can you confirm the use case or provide screenshots of the page after modifying it?  It looks like you are trying to create shortcut buttons so that instead of the agent selecting the COE and Service from the drop-down, they click a button on the page that pre-populates the COE and Service and then creates the case.  Is that correct?

_ _ _ _
ServiceNow Employee
ServiceNow Employee

It fails to retrieve the service because you did not set the sys_id for the #service_input option.

The values to set for the #service_input are sys_id, coe, display, template, parent, e.g.:

$j("#service_input").select2("data", { sys_id: 'SERVICE_SYS_ID', coe: 'sn_hr_core_case_payroll', display: 'Payroll Discrepancy', template: 'TEMPLATE_SYS_ID', parent: 'Topic Category Name' });

Note: There is extra logic on the page that you may be skipping by bypassing the normal route.

Dallas16
ServiceNow Employee
ServiceNow Employee

Thank you! This worked perfectly for what I was trying to achieve. 

manasamaniac
Mega Expert

Hi SN Team,

 

In a similar way i want line of code similar to above stmt in setting Opened for (small f and refers to users table) with value selected in Opened For (capital F refers to HR Profile) on click of "create Case" button. 

 

find_real_file.png

 

Thanks

Manasa