Auto assign user based on employment type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
user whose hr profile meet these conditions like employement type is contractors they should be auto assigned to contractor external role( global scope)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
To automatically assign a user to a "Contractor" role (Global Scope) based on their employment type in the HR Profile, the recommended ServiceNow approach is to use a Business Rule on the sn_hr_core_profile table
- Identify the Role: Ensure the "Contractor" role exists in the global scope (e.g., contractor_external).
- Create a Business Rule:
- Table: HR Profile [sn_hr_core_profile]
- When: after (insert or update)
- Order: 100
- Conditions: Employment type changes to Contractor
- Script: (update script as per your requirement)
Submit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
what's your actual business requirement?
question is not clear.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Ankur Bawiskar ,
- Auto Assign a role to user whose Hr Profile meets the below condition like employment type is Contractor using client role assignment rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @sreeha
To automatically assign a user to the Contractor External role (Global Scope) based on their HR Profile employment type, the recommended approach in ServiceNow is to use a Business Rule on the HR Profile table.
Step 1 — Verify the Role exists: Make sure the contractor_external role exists in the Global scope before proceeding.
Step 2 — Create a Business Rule:
Field Value
| Table | HR Profile [sn_hr_core_profile] |
| When | After (Insert or Update) |
| Order | 100 |
| Condition | Employment Type changes to Contractor |
Step 3 — Add the Script:
(function executeRule(current, previous) {
var userId = current.user.toString();
if (!gs.isEmpty(userId)) {
var roleAssign = new GlideRecord('sys_user_has_role');
roleAssign.initialize();
roleAssign.user = userId;
roleAssign.role = gs.getRoleID('contractor_external');
roleAssign.insert();
}
})(current, previous);⚠️ Note: Update the script as per your specific business requirements and always test in a sub-production instance before deploying to production.
Hope this helps! ,if yes kindly mark helpful & Accept as Solution😊
Regards
Sumit
