Making Contact field dependent on Account in Requested Item

RohitD027682673
Tera Contributor

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?



4 REPLIES 4

Ankur Bawiskar
Tera Patron

@RohitD027682673 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 
Thank you for your response.
Please find attached a screenshot of the requested item. I hope this is helpful.

@RohitD027682673 

so what script did you create on RITM to handle the requirement?

did you debug why it's not working?

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

gaurrohi
Tera Expert

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;
 

Screenshot 2026-04-01 113323.png

Please mark the response as the correct answer and helpful. This may help other community users to follow the correct solution.

Regards,
Rohit Singh