Population HR Case -opened for User name to Short description of HR Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 08:37 AM
I have a requirement include Opened for user name in Hr Task form short description field
i created business rule but not working as expected .can somebody help me on this to sort out ?
Advance Thanks
Here below short description field have to append Opened for user name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 08:38 AM
Added business rule but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 05:19 AM
Hi @Bhavani3 try below code
(function executeRule(current, previous /*null when async*/) {
var hrCase = current.case;
if (hrCase) {
var hrCaseRecord = new GlideRecord('sn_hr_core_case');
if (hrCaseRecord.get(hrCase))
var openedForUser = hrCaseRecord.opened_for;
if (openedForUser) {
var userName = openedForUser.getDisplayValue();
current.short_description = hrCaseRecord.short_description + ' - Opened for ' + userName;
} else {
gs.log('Opened for user not found for HR Case: ' + hrCase);
}
} else {
gs.log('HR Case record not found for sys_id: ' + hrCase);
}
} else {
gs.log('HR Case sys_id is empty or undefined');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 08:41 AM
The below code is running each time and in short description field of hr task displays the user name duplicates name
BR-table-hr case condition-before-insert,update

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 08:57 AM
@Bhavani3 Simply use the following script on an onBefore insert business rule on sn_hr_core_case table.
current.short_description = current.short_description + ' - Opened for ' + current.opened_for.name;
Hope this helps.