- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 12:18 PM
There is a related list on the account table called Account Team Members [sn_customerservice_team_members]. I want to add this related list to the Case table/form [sn_customerservice_case]. I have created a new relationship between these 2 tables. The relationship I created shows 'Applies to table' as [sn_customerservice_case], and 'Queried from table' is [sn_customerservice_team_member]. I've added it to the Case form as a related list. On a Case that's associated/opened against the Account that has the team member records, I'm seeing all team member records from all Accounts, and not just the team members created against the Account the Case is created against. Why am I seeing all team member records against all Accounts, and not just the ones created against the Case Account? Below is the Relationship 'Query with' script:
(function execute(/* GlideRecord */ current) {
if (!current.account) {
return null; // No account, no related records
}
var teamMembers = new GlideRecord('sn_customerservice_team_member');
teamMembers.addQuery('account', current.account); // Match the account
teamMembers.query();
return teamMembers; // Return filtered records
})(current);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 02:03 PM
Hi @MStritt
Okay, in that case try this one...
(function refineQuery(current, parent) {
// Ensure the 'account' field from the parent case matches the 'account' field in the account team members table
current.addQuery("account", parent.account);
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 02:03 PM
Hi @MStritt
Okay, in that case try this one...
(function refineQuery(current, parent) {
// Ensure the 'account' field from the parent case matches the 'account' field in the account team members table
current.addQuery("account", parent.account);
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 02:14 PM
That did it. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 02:27 PM
You're welcome! Glad its sorted.