Need to pull a value from the Opened For's HR Profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 01:44 PM
I want to add a value from the Opened For's HR Profile to a tab on the case form. When I go to add fields, it only gives me access to the Subject Person's HR Profile. Is there a way I can make a field with this information? Or do I only have access to pull from the Opened For/By's User Profile?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 10:44 PM
by default, the case form displays information from the Opened By's User Profile and not the Opened For's HR Profile. However, you can customize the form to add a field that displays information from the Opened For's HR Profile. Here's a general approach to achieve this:
Identify the HR Profile field: Determine the specific HR Profile field on the User table that corresponds to the Opened For user. You'll need the field name to reference it in your customization.
Create a new field on the case table: Navigate to the Case table's dictionary (e.g., sys_dictionary.list.do?sysparm_query=name%3Dincident). Create a new field that will hold the value from the Opened For's HR Profile. Choose an appropriate field type based on the HR Profile field you identified in step 1.
Write a business rule or client script: Create a business rule or client script that runs on the Case table when a record is loaded. In the script, retrieve the value from the Opened For's HR Profile field and set it in the newly created field on the Case table.
Here's an example of a client script that retrieves the HR Profile value from the Opened For user and sets it in a field named opened_for_hr_profile on the Case table:
function onLoad() {
var openedFor = g_form.getValue('opened_for'); // Assuming 'opened_for' is the reference field for Opened For user
if (openedFor) {
var openedForUser = new GlideRecord('sys_user');
if (openedForUser.get(openedFor)) {
var hrProfileValue = openedForUser.<hr_profile_field>; // Replace '<hr_profile_field>' with the actual HR Profile field name
g_form.setValue('opened_for_hr_profile', hrProfileValue);
}
}
}
Please mark helpful
Mzhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 06:38 AM
I feel like I'm really close, but it isn't working. Do you notice anything I need to change? I put a screenshot of my Client Script, my new field (u_donator_current_top_balance), and the existing field I'm trying to pull from the Opened For's HR Profile (u_top_available).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 06:38 AM
Sorry, I forgot to include my script.
function onLoad() {
//Type appropriate comment here, and begin script below
var openedFor = g_form.getValue('opened_for'); // Assuming 'opened_for' is the reference field for Opened For user
if (openedFor) {
var openedForUser = new GlideRecord('sys_user');
if (openedForUser.get(openedFor)) {
var hrProfileValue = openedForUser.u_top_available;
g_form.setValue('u_donator_current_top_balance', hrProfileValue);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 07:29 AM
Please use below corrected code
function onLoad() {
var openedFor = g_form.getReference('opened_for', doAlert); // doAlert is our callback function
function doAlert(openedFor) {
var hrProfileValue = openedFor.u_top_available;
g_form.setValue('u_donator_current_top_balance', hrProfileValue);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2023 07:58 AM