Script include (reference qualifier)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:37 AM
There is two reference fields.one is account and second one is assignment group.when we select account and assignment group then both account and assignment group common users should be available in assigned to field.how to achieve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:44 AM
Make assigned to field dependent on assignment group field.
Write advance reference qualifier to get user based on assignment group and account ( not sure how account number is relevant to user table but you can add that relation ship in script include).
Please mark as correct or helpful based on the impact.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:48 AM
Hi @dhcd
In your Dependent field, populate 'assignment_group'.
You just need to write below code in your Advance Reference Qual:
javascript: "account=" + current.u_account;
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:53 AM
Hi, if you are achieving through portal you should use 2 approaches
1. Create 2 fields are look up select box and define the variable attribute like below
2. Use the reference field and configure the variable attributes like below. Use the required field name in ac_columns field.
ref_auto_completer=AJAXTableCompleter,ref_ac_columns=user_name,ref_ac_columns_search=true,ref_ac_order_by=name
If you want to achieve through platform, you should use 'Dependent Field' in dictionary field.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 05:55 AM
hello @dhcd ,
you need to call a script include in your assigned to field advanced reference qualifier like below
syntax:
javascript:new your_Script_include_name().your_function_name(your parameters)
Example reference qualifier :
javascript:new getAssignmentGroupMembers().getUsers(current.assignment_group)
In the above line i just passed current.assignment_group as a parameter .But in your case you need to pass your account also as javascript:new getAssignmentGroupMembers().getUsers(current.assignment_group ,current.your_account_field_name);
Script include:
this script catches the selected assignment group as a parameter and then queries the group member table to push all the selected group members into an array and then return the sys_ids of those users.
Now in your script you might have to catch the account also as a parameter and then glide record to the table where account users are stored and push those users into same array
var getAssignmentGroupMembers = Class.create();
getAssignmentGroupMembers.prototype = {
initialize: function() {
},
getUsers:function(group)
{
var users=[];
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group',group);
gr.query();
while(gr.next())
{
users.push(gr.sys_id.toString());
}
return "sys_idIN"+users.toString();
},
type: 'getAssignmentGroupMembers'
};
Hope this helps
Mark my answer as correct if this helps you
Thanks