How to populate incident records based on check box
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 10:41 AM
Hello Experts,
I created 2 fields in XYZ record producer.
1. ABC ( field type is checkbox)
2. Select Incident ( field type is reference to incident table)
Now my requirement is
If ABC is false then in Select Incident field we need to populate my incident records only.(means caller = current logged in user )
If ABC is true the in Select Incident field we need to populate all incident records.
How to achieve this...?
Best regards,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 10:57 AM
Hi @raj149 ,
For Select Incident, write script include and call that using GlideAjax and get the list of incident for selection.
In script include, glide the incident table with condition on caller field passed from GlideAjax along with checkbox value.
Write some draft code and share if you need some help.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:03 AM
Hello @AshishKM
I am trying with below Script include and catalog client script but it is not working
Script include is
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetUserInc');
ga.addParam('sysparm_name','getIncidents');
ga.addParam('sysparm_user',g_user.userID);
ga.addParam('sysparm_all',newValue);
ga.getXMLAnswer(handleResponse);
}
function handleResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var incidents = JSON.parse(answer);
g_form.clearOptions('incident1');
incidents.forEach(function(incident){
g_form.addOption('incident1',incident.sys_id,incident.number);
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:13 AM
Hey @raj149,
Are you referring to applying a reference qualifier on the 'Select Incident' variable? i.e. instead of populating the variable, you want to filter the list of records that can be selected.
If so, create a Script Include and use the 'Advanced' reference qualifier. For details, refer to another article - https://www.servicenow.com/community/itsm-articles/reference-qualifier/ta-p/2306509
Just as an example, your reference qualifier will be something like:
javascript: new yourScriptInclude().getQualifier(current.variables.abc);
And your function in the script include will be
getQualifier: function(abc){
if(abc == true)
return "caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe"
else
return "";
}
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:14 AM - edited 02-26-2024 11:14 AM
Hi,
This functionality can be achieved by adding an advance reference qualifier on the Select Incident field.
If you need guidance to configure advance reference qualifier I will help you out.
Regards,
Sasikanth