Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

hr_Utils- Scoped

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.

Parent Topic:Server API reference

hr_Utils - hr_Utils()

Instantiates an instance of the hr_Utils class.

NameTypeDescription
None  

hr_Utils - getPrimaryJob(String userId)

Gets the Sys ID of the active primary job for a provided user.

NameTypeDescription
userIDStringSys ID of the HR user from the User [sys_user] table assigned an active or future job in which Primary is true.
TypeDescription
StringIf present and active, Sys ID of the primary job from the Jobs [sn_hr_core_job] table, null otherwise.
var result = new sn_hr_core.hr_Utils().getPrimaryJob('5137153cc611227c000bbd1bd8cd2007');
gs.info('Result: ' + result);

Output:

Result: eb3c69463cd63740964fb8b1ce04f9ae

hr_Utils - switchPrimaryJob(String userId String jobId)

Switches the primary job of a user.

NameTypeDescription
userIdStringSys ID of HR user from the Users [sys_user] table.
jobIdStringJob Sys ID from the Jobs [sn_hr_core_job] table.
TypeDescription
StringEncoded JSON with message and status, error otherwise.
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"}