How to populate realated Location field as per the selected account on case form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 03:16 AM
Hello,
On the csm case form there are 2 fields named as account (customer_account) and location (cmn_location) both fields are reference fields. So basically want to populate the location which is related to that account. Please help me into that..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 05:55 AM
Hi @aakankshapl
I think you will have to make a reference on cmn_location with customer_account table. So as soon as you will fill the account value on case form, location will be populated automatically.
Please try once.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 08:34 PM
Hi @Amit Pandey
Thank you for you suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 08:54 PM - edited 03-16-2024 08:55 PM
Hello Everyone,
I got the solution to problem.
So on my case form 2 fields Account and Location and both field are reference to customer_account and cmn_location. basically I wanted to populate the location when I select any account in account field, that location should be related to them. So I locate the common relationship between these 2 tables that was Company ID.
For that I created a script include and call that script include in location field reference qualifier. Below is the code of scipt include:
var LocationFilter = Class.create();
LocationFilter.prototype = {
initialize: function() {
},
refqualassignedto: function(account) {
//var accountName = 'Puma'; //this.getParameter('account'); // your assignment group variable name
var location = [];
if (account != '') {
var grAcc = new GlideRecord('customer_account');
grAcc.addQuery('sys_id', account);
grAcc.query();
if (grAcc.next()) {
var grLoc = new GlideRecord('cmn_location');
grLoc.addQuery('company.u_company_id', grAcc.u_company_id);
grLoc.query();
gs.info('test1'+ grLoc.getRowCount());
while (grLoc.next()) {
location.push(grLoc.getUniqueValue());
}
}
return 'sys_idIN' + location;
}
},
type: 'LocationFilter',
};
And call the below script include in location fields reference qualifier:
javascript:new global.LocationFilter().refqualassignedto(current.account);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 11:44 PM
@Bingo @aakankshapl 😇
You found a solution to your own problem and shared it here to help others who might face the same issue in the future. Nice gesture! Keep it up.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 09:21 PM
Thank You @Amit Pandey 😊