---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# hr_Utils - Scoped

# hr_Utils - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The hr_Utils API provides basic functionality for the Human Resource (HR) application.

This API requires the HR core plugin (com.sn_hr_core) and runs in the `sn_hr_core` namespace.

## hr_Utils - hr_Utils() {#ariaid-title2}

Instantiates an instance of the hr_Utils class.
{#hrU-hr_Utils__table_wyr_ql2_vhb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#hrU-hr_Utils__table_wyr_ql2_vhb}

## hr_Utils - getPrimaryJob(String userId) {#ariaid-title3}

Gets the Sys ID of the active primary job for a provided user.
{#hrU-getPrimaryJob_S__table_jsg_hn2_vhb__entry__3}

| Name | Type | Description |
|-|-|-|
| userID | String | Sys ID of the HR user from the User \[sys_user\] table assigned an active or future job in which Primary is true. |
[Table 2. Parameters]

{#hrU-getPrimaryJob_S__table_jsg_hn2_vhb} {#hrU-getPrimaryJob_S__table_ksg_hn2_vhb__entry__2}

| Type | Description |
|-|-|
| String | If present and active, Sys ID of the primary job from the Jobs \[sn_hr_core_job\] table, null otherwise. |
[Table 3. Returns]

{#hrU-getPrimaryJob_S__table_ksg_hn2_vhb}  

    var result = new sn_hr_core.hr_Utils().getPrimaryJob('5137153cc611227c000bbd1bd8cd2007');
    gs.info('Result: ' + result);

Output:

    Result: eb3c69463cd63740964fb8b1ce04f9ae

## hr_Utils - switchPrimaryJob(String userId String jobId) {#ariaid-title4}

Switches the primary job of a user.
{#hrU-switchPrimaryJob_S_S__table_jz3_jn2_vhb__entry__3}

| Name | Type | Description |
|-|-|-|
| userId | String | Sys ID of HR user from the Users \[sys_user\] table. |
| jobId | String | Job Sys ID from the Jobs \[sn_hr_core_job\] table. |
[Table 4. Parameters]

{#hrU-switchPrimaryJob_S_S__table_jz3_jn2_vhb} {#hrU-switchPrimaryJob_S_S__table_kz3_jn2_vhb__entry__2}

| Type | Description |
|-|-|
| String | Encoded JSON with message and status, error otherwise. |
[Table 5. Returns]

{#hrU-switchPrimaryJob_S_S__table_kz3_jn2_vhb}  

    var result = new sn_hr_core.hr_Utils().switchPrimaryJob('5137153cc611227c000bbd1bd8cd2007', 'bc884e723c0ebf00964fb8b1ce04f9d7');
    gs.info('Result: ' + result);

Output:

    Result: {"message":"Switched primary job for the user successfully","status":"success"}


