from users email, i want contacts account locations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 06:01 AM
I have created one record Producer, which consists of two Variables, one is requestor_name and the other one is meeting_event_location.
The Requestor_name is referring to sys_user table and the meeting_event_location referring to cmn_location table
I want that from user email, i want to fetch the contact account locations, i have written the below script include for that, but its not working. can someone please help me why this script is not working, this script is working for logged in user, how i can make for all users?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 06:57 AM
Hi,
Please try passing the value instead current while you call your script include
javascript:new sn_customerservice.locationlist().accountLocation(current.variables.<userVariable>)
This would take sys id if the user selected un user field and pass the same to your script include so that you do not have to use logged in user, instead you can use the user you have passed from the variable.
Rest all should work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2023 07:05 AM
var LocationListScript = Class.create();
LocationListScript.prototype = {
initialize: function() {},
accountLocation: function(userEmail) {
var contact = new GlideRecord('customer_contact');
contact.addQuery('email', userEmail);
contact.query();
if (contact.next()) {
var accountId = contact.getValue('account');
var locationlist = [];
var loclist = new GlideRecord('cmn_location');
loclist.addQuery('account', accountId);
loclist.query();
while (loclist.next()) {
locationlist.push(loclist.getValue('sys_id'));
}
return 'sys_idIN' + locationlist.join(',');
}
return ''; // Return an empty string if no locations are found
},
type: 'LocationListScript'
};
and it in reference Qualifier
javascript:new LocationListScript().accountLocation(gs.getUser().getEmail())