- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 11:58 PM
I have 2fileds one is list for responsible group which is a list type and the other one is responsible dl i would like to auto populate dl if the user select the groups from the list using glide ajax i have written script but it's not working
Script include
Script include
var ResponsibleTeamHandler = Class.create();
ResponsibleTeamHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fetchGroupEmails: function() {
var teamIds = this.getParameter('sysparm_teams');
if (!teamIds) {
return '';
}
var teamEmails = [];
var teamIdsArray = teamIds.split(',');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', 'IN', teamIdsArray);
gr.query();
while (gr.next()) {
if (gr.email) {
teamEmails.push(gr.email.toString());
}
}
return teamEmails.join(', ');
},
type: 'ResponsibleTeamHandler'
});
Client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('ResponsibleTeamHandler');
ga.addParam('sysparm_name', 'fetchGroupEmails');
ga.addParam('sysparm_teams', newValue);
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_responsible_team_dls', answer);
});
// Add any additional code required here
}
Kindly help in resolving the issue
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2025 09:12 PM
This worked and Thanks for the support I changed a few. @Viraj Hudlikar @NagaChandaE and @Ankur Bawiskar
here is the code
Script include
var ResponsibleTeamHandler = Class.create();
ResponsibleTeamHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fetchGroupEmails: function() {
var teamIds = this.getParameter('sysparm_teams');
if (!teamIds) {
return '';
}
var teamEmails = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', 'IN', teamIds);
gr.query();
while (gr.next()) {
if (gr.email) {
teamEmails.push(gr.email.toString());
}
}
return teamEmails.join(', ');
},
type: 'ResponsibleTeamHandler'
});
Client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('ResponsibleTeamHandler');
ga.addParam('sysparm_name', 'fetchGroupEmails');
ga.addParam('sysparm_teams', g_form.getValue('u_responsible_teams'));
ga.getXMLAnswer(function(answer) {
g_form.setValue('u_responsible_team_dls', answer); // Set the response in the desired field
});
// Add any additional code required here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2025 12:37 AM
Are you want to get group emails or user email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2025 12:42 AM
Group email id @NagaChandaE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2025 12:42 AM - edited ‎01-24-2025 12:44 AM
Script include
var ResponsibleTeamHandler = Class.create();
ResponsibleTeamHandler.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fetchGroupEmails: function() {
var teamIds = this.getParameter('sysparm_teams');
if (!teamIds) {
return '';
}
var teamEmails = [];
var teamIdsArray = teamIds.split(',');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', 'IN', teamIdsArray);
gr.query();
while (gr.next()) {
if (gr.email) {
teamEmails.push(gr.email.toString());
}
}
return teamEmails.join(', ');
},
type: 'ResponsibleTeamHandler'
});
I have changed the querying with sys_id instead group try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2025 12:10 AM
Hello @VinuvarshitSR
In your script did you tried to add log in script include if correct data is passed or not, also in client script add alert statement when answer is return and see what value is returned?
Also, the responsible dl field is of string type I believe.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2025 12:13 AM
Yes i have tried to debug it. I was not able to come up with solution that's why reaching out. Yes it is a string field
Thank you - Viraj