The CreatorCon Call for Content is officially open! Get started here.

HR Agent workspace - inidication for case created from WS

tpeleg
Tera Expert

Hello experts,

 

we have a business requirment to auto assign the new case to the the opened by user (supporter  -on behalf of the subject person), if the case was raised from case  the HR agent workspace (if from service portal - no auto assignment). 

any suggestions? if there is an indication for the case source it can be a solution because then I could run a BR for auto assignment after creation.

 

Thanks.

1 ACCEPTED SOLUTION

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Alright, here's an easier solution:

 

  1. Create a new business rule on the target table, e.g. sn_hr_core_case.
  2. Configure the BR with Advanced set to true, Before Insert, and add any conditions you want, e.g. HR Service, etc.
    LaszloBalla_0-1692884376091.png
  3. In the Advanced tab, add the following lines of code
    • Condition: 
      gs.action.getGlideURI().toString().includes('api/now/')​
    • Script: 
      current.setValue('assigned_to', current.getValue('opened_by'));​

       

      LaszloBalla_1-1692884700038.png

       

  4. Save the Business Rule

I have tested the above and it works fine for me (Vancouver, but I believe earlier versions should work the same way).

 

Hope it helps!

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@tpeleg You can create a custom field on the HR Case. This custom field can be populated using a client script for e.g.

function onLoad() {  
    var view = getView();  
  if (view == 'workspace'){   
  g_form.setValue('u_case_source','workspace');  
  }  
}  

This way you will be able to identify the case generated through workspace.

Or skip the custom field entirely, and put this logic in an onsubmit client script to set the assignee field directly.

tpeleg
Tera Expert

Hi and thank you @Laszlo Balla  & @Sandeep Rajput .

great idea, but i'm working inside the OOTB page (now/hr/agent/case-creation-page). how can I write client script for this page?

 

tpeleg_0-1692810962766.png

 

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Alright, here's an easier solution:

 

  1. Create a new business rule on the target table, e.g. sn_hr_core_case.
  2. Configure the BR with Advanced set to true, Before Insert, and add any conditions you want, e.g. HR Service, etc.
    LaszloBalla_0-1692884376091.png
  3. In the Advanced tab, add the following lines of code
    • Condition: 
      gs.action.getGlideURI().toString().includes('api/now/')​
    • Script: 
      current.setValue('assigned_to', current.getValue('opened_by'));​

       

      LaszloBalla_1-1692884700038.png

       

  4. Save the Business Rule

I have tested the above and it works fine for me (Vancouver, but I believe earlier versions should work the same way).

 

Hope it helps!