- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 07:58 AM
I have Company Field (Field: company, Table: core_company) on Incident Form. I want to populate Assignment group(Field: assignment_group, Table: sys_user_group) based on value selected in company field. How can this be achieved with Ajax calls.
I have tried using reference qualifier but seems it isn't working.
I have created a m2m mapping between the 2 tables in u_m2m_group_companies.
Advance Reference Qualifier used :
Script Include :
var BackfillAssignmentGroupCompany = Class.create();
BackfillAssignmentGroupCompany.prototype = {
initialize: function() {
},
BackfillAssignmentGroupCompany:function() {
var gp = ' ';
var a = current.company;
//return everything if the company value is empty
if(!a)
return;
//u_m2m_groups_companies has the user to group relationship
var grp = new GlideRecord('u_m2m_groups_companies');
grp.addQuery('u_company',a);
grp.query();
while(grp.next()) {
if (gp.length > 0) {
//build a comma separated string of groups if there is more than one
gp += (',' + grp.u_group);
}
else {
gp = grp.u_group;
}
}
// return Groups where assigned to is in those groups we use IN for lists
return 'sys_idIN' + gp;
},
type: 'BackfillAssignmentGroupCompany'
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 08:07 AM
Hi Anirudh,
If you have a field on assignment group which refers to company table then this can be achieved directly through simple reference qualifier
If not then you will have to use advanced reference qualifier and why you need Ajax call. It will be a server side code.
https://docs.servicenow.com/bundle/jakarta-platform-administration/page/script/server-scripting/concept/c_ReferenceQualifiers.html
https://community.servicenow.com/community?id=community_question&sys_id=9561d72ddbdcdbc01dcaf3231f961990
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 08:07 AM
Hi Anirudh,
If you have a field on assignment group which refers to company table then this can be achieved directly through simple reference qualifier
If not then you will have to use advanced reference qualifier and why you need Ajax call. It will be a server side code.
https://docs.servicenow.com/bundle/jakarta-platform-administration/page/script/server-scripting/concept/c_ReferenceQualifiers.html
https://community.servicenow.com/community?id=community_question&sys_id=9561d72ddbdcdbc01dcaf3231f961990
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 08:33 AM
Are you aware how to get Company to Assignment group relationship ? which table stores it ?
if not how can I achieve one ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 09:17 AM
Thanks, this worked out.