Related list to show case ticket of parent account and child account in parent account- 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 01:30 AM
Need to create Related list to show case tickets of parent account and child account in parent account form and for child account it should show only child account mapped case ticket.
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
// var casesGr = new GlideRecord('sn_customerservice_case');
// casesGr.addQuery('account', current.sys_id);
// // var querys = 'account=' + current.sys_id;
// caseGr.query();
// if (current.sys_id == parent.account) {
var querys = 'account=' + current.sys_id;
var childAccountGr = new GlideRecord('customer_account');
childAccountGr.addQuery('account_parent', current.sys_id);
childAccountGr.query();
var childAccoundIds = [];
if (childAccountGr.next()) {
childAccoundIds.push(childAccountGr.sys_id.toString());
}
gs.log("show accounts" + childAccoundIds);
if (childAccoundIds.length > 0) {
querys += "^ORaccountIN" + childAccoundIds.join(',');
} else {
querys = "account=" + current.sys_id;
}
gs.log("show query" + querys);
current.addEncodedQuery(querys);
//current.addEncodedQuery('account='+parent.sys_id);
})(current, parent);
This is not working as expected it is showing all the case tickets for all account
What i required is if parent account has 4 tickets and child account for this particular parent account has 10 tickets and total of 14 tickets need to show parent ticket but for child tickets should show only tickets mapped to that account in case form (in case form we have a field "account" which referred to account table).
the way to find the child accounts is that in account table we have a field "parent account" if any accounts had mentioned parent account, then that account would be child account of that mentioned parent account field.
currently after the above code it is fetching all accounts; it is showing all the tickets for all the accounts. It need to show specific tickets for the parent account and its child account tickets.
Please help me on this.
Regards,
Joyal Robert
0 REPLIES 0