Array in client script Help!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 08:17 PM
Hi All, I have a assignment group list array in client script I want NOT to show a field if incident assignment group contains one of this group.
var arrayList = ['test1','test2','test3'];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 09:37 PM
Hi Malu,
What you can do is get the group name present on incident form and search it in this array
var incidentGroupName = g_form.getValue('assignment_group');
query group table with this sys_id and then get name in variable b
var arrayList = ['test1','test2','test3'];
var arrayUtil = new ArrayUtil();
var isContained = arrayUtil.contains(arrayList, b);
if(isContained){
// found
// do your stuff i.e. show, hide etc
}
else{
// not found
}
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
‎01-14-2017 10:51 PM
Can be done like below too:
var grpNames=['test1','test2','test3'];
var hasGrp=0;
var chkAssignGrp=g_form.getDisplayBox('assignment_group').value;
for(var i=0;i<grpNames.length;i++)
{
if(grpNames[i]==chkAssignGrp)
hasGrp='1';
}
if (hasGrp=='1')
{//do your stuff
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-14-2017 10:57 PM
Hi Malu,
You can write down below code
var currentGroup = g_form.getValue('assignment_group').toString();
var groupList = ['group1id','group2id'];
groupString = groupList.join(',');
if (groupString.indexOf(currentGroup) > -1) { // current group exits in group list
do this;
return;
}
do that;
return;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2017 03:35 AM
Hi Malu,
Did you try the solution proposed by me in the comment?
you can let me know if any issue.
If already resolved you can mark the answer as correct and hit like and helpful. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader