Auto-populate the assigned to field within the Hardware New record with a business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2025 06:01 AM
Hi,
I am trying to auto-populate the 'Assigned to' field in the Hardware New record with the user from the 'Requested for' field in the Requested Item, after the RITM number is populated in a custom field called 'RITM Number' in the Hardware New record.
I tried to auto-populate the 'Assigned to' field with a business rule I created, but whenever I add an RITM number to my custom field in the Hardware New record, the 'Assigned to' field remains empty.
My steps:
1. Accessed the business rules under system definition.
Created a business rule new record:
1. Advanced = checked
When to run:
1. When = before.
2. Update = checked.
Advanced:
1. I created a custom script.
See Assigned to1 and Assigned to2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2025 06:45 AM
Okay, I checked the Insert box and unchecked the update box, and got the same result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2025 06:57 AM
The more correct Condition on insert would be
current.assigned_to.nil() && !current.u_ritm_number.nil()
but let's remove that for now just to get this running. Just to confirm understanding, the BR does not actually run until the record is created, so the Submit button is clicked in this scenario, so you should see the Assigned to populated after you click Submit. If it's still not working with the Condition removed, let's add some logging to the script to find out what's going on:
(function executeRule(current, previous /*null when async*/) {
gs.addInfoMessage('Assigned to is ' + current.assigned_to + ' RITM number is ' + current.u_ritm_number.number + ' RITM Request for is ' + current.u_ritm_number.requested_for.name);
current.assigned_to = current.u_ritm_number.requested_for;
})(current, previous);
This should show at the top of the new record after it is created. Please send a screenshot of the new hardware record form with this message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2025 07:01 AM
Okay, let me see.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2025 07:28 AM
Looks like this worked, but as you said, the script can only auto-populate after you create the hardware record, then the user on the 'Requested for' field will appear to be 'Assigned to' field under the CMDB CI list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2025 08:11 AM
If you want to see the Assigned to populate on the form right after you populate the RITM field, instead of the Business Rule you'll need an onChange Client Script on the alm_hardware table when RITM Number changes:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// Populate Assigned to with Requested for of RITM when RITM changes
g_form.getReference('u_ritm_number', setUser);
}
function setUser (ritm) {
g_form.setValue('assigned_to', ritm.requested_for);
}
