Dependent field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 03:02 AM
Hi All,
On the incident form, there is a Location and an Account field. I want to display the Locations based on the Account selected, i.e. only the locations which are for the selected account will show. I have tried adding 'company' as the dependent field:
However, that works only for some accounts. For others, it shows either some or no locations at all.
I also tried creating a Dictionary Override for the Incident table (removing the default dependent) which looks like this:
But this is not working as well. Can anyone please let me know if I am doing anything wrong, or any alternative solution?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 03:37 AM - edited 06-28-2024 03:38 AM
hello @tanaya ,
Try the OnChange (and , or onload)Client script by refering and updating below script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var accountFor = new GlideRecord('account');
accountFor.addQuery('sys_id',newValue);
accountFor.query();
while(accountFor.next()) {
g_form.setValue('location',accountFor.location);
}
}
Also refer the below article for similar requirement:
https://www.servicenow.com/community/developer-forum/autofill-location-based-on-user/m-p/2142708
https://www.servicenow.com/community/developer-forum/need-to-populate-location-field-based-on-the-co...
https://www.servicenow.com/community/itsm-forum/auto-populate-location-location-based-on-the-users-s...
If my solution helps you any way then mark it as accepted and helpful.
Thank You!!
Thank you!!
Dnyaneshwaree Satpute
Tera Guru