how can we check one dot walk field & list collector field on the form selected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:22 AM
we have onchange client sctipt on priority field. when the priority changes to critical, then it has to check two fields, if those fields contains the values then it should not pop up, other wise show pop up.
the fisrt field is reference field assignemnt group, and we have to dot work to the selected assignement group record (remote system)
another field is list collector field type (glide_list). we have to theck if this field contains the value UD in it.
//----------------------check assignment group.remote system field coniatins UD-------------//
var asgnmntgrp = g_form.getDisplayBox('assignment_group').value;
var remote = String(asgnmntgrp.u_remote_system).indexOf('UD');
alert('After getting remote' + remote);
//---------------check list collecter field values contains UD -------------//
var ip = g_form.getValue('u_partner_integrated') + '';
var ip2 = ip.indexOf('UD');
alert('After getting ip' + ip2);
currently there is no value coming in the alert , please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:29 AM
Hi Roxi,
indexOf function returns a index, so you must add an in statement for showing or not your alert. Is the string it's not found it will return -1. I guess that you are not taking any alert from the second one.
Using if statement should be something as follows:
var ip = g_form.getValue('u_partner_integrated') + '';
var ip2 = ip.indexOf('UD');
if(ip2 == -1) {
alert('Not found -> After getting ip' + ip2);
}else{
alert('Found -> After getting ip' + ip2);
}
https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
If it was helpful, please give positive feedback.
Thanks,
☆ Community Rising Star 22, 23 & 24 ☆

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:32 AM
Try below
var asgnmntgrp = g_form.getReference('assignment_group',callback);
function callback(asgnmntgrp)
{
var rsystem=asgnmntgrp.u_remote_system;
if(rsystem.indexOf('UD')>-1)
{
alert('After getting remote' + remote);
}
}
Apply same for u_partner_integrated as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:37 AM
Hi,
you cannot dot walk list collector field using getReference()
you can use getReference on reference field and get the u_remote_system
So the only way is to use onChange + GlideAjax and check this logic in Script include function
1) query the table with those sysIds and check the value by comparing it
I hope you must be comfortable with GlideAjax
Regards
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
‎06-08-2022 07:38 AM
we don't need to dot walk list collector field, just want to check and alert the field value selected.
and can you help with the script include and client script Ankur to check the assignment group field and ownership group contain UD
this is the script include and client script i created but it seems some issues with it , please look and correct if any mistakes done
here we are trying to check the assignment contains UD in it or not , if yes no alert, if NO then has to alert this
client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if ((g_form.getValue('priority') == '1')) {
var asmtngrpselected = g_form.getDisplayBox('assignment_group').value;
alert(asmtngrpselected);
var ga = new GlideAjax('CheckUD');
ga.addParam('sysparm_name','containsUD');
ga.addParam('sysparm_assignmentgrp',asmtngrpselected);
ga.getXML(getUDcontains);
function getUDcontains(response){
var asgnmgrpcontains = response.responseXML.documentElement.getAttribute("answer");
if(asgnmgrpcontains ==-1) {
alert(new GwtMessage().getMessage("TEST"));
}
}
}
}
Script include:
var CheckUD = Class.create();
CheckUD.prototype = Object.extendsObject(AbstractAjaxProcessor, {
containsUD:function(){
var incobj = {};
var gr = new GlideRecord('incident');
if(gr.get(this.getParameter('sysparm_assignmentgrp'))){
incobj.asgnmntgrp = g_form.getDisplayBox('assignment_group').value;
var asignmentgrpvgcs = String(asgnmntgrp).indexOf('UD');
}
type: 'CheckVGCS'
}
}
);