Making Contact field dependent on Account in Requested Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello Everyone,
I have a field named Contact on the Requested Item that is currently not dependent on any other field. I would like to make it dependent on the Account field.
At present, any user can be selected as a Contact for any Account. Ideally, when the Account changes, the Contact field should be cleared, and users should only be able to select Contacts associated with the selected Account.
This behavior is already working as expected for Cases and Incidents. Whenever the Account field is updated, the Contact field is cleared, and users can only select Contacts related to that specific Account. One difference I noticed is that, in Cases and Incidents, the Contact field is mandatory, whereas in Requested Items it is not.
To achieve this, I created the following Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
g_form.clearValue('requested_for');
}
The script is configured to run onChange of the Account field on the Task table (since the Account field is defined there). Contact column is on Request table with reference type and with 'requested_for' as a column name. However, it is not producing the expected result.
Could someone please guide me on how to properly implement this dependency?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
46m ago
account and contact makes sense for CSM cases etc
How does it relate to RITM?
Since your contact field is on RITM then you need to have logic on that table
share some screenshots
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
42m ago
@Ankur Bawiskar
Thank you for your response.
Please find attached a screenshot of the requested item. I hope this is helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
36m ago
so what script did you create on RITM to handle the requirement?
did you debug why it's not working?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
33m ago - last edited 27m ago
Hi @RohitD027682673,
Since you want to make the contact dependent on the account you can use the advanced reference qualifier in the contact field which will only the contacts associated with the accounts selected in the form
javascript: 'account=' + current.field_name;Regards,
Rohit Singh
