- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 05:21 AM - edited ‎02-22-2024 05:23 AM
The main form includes a reference type variable "user_submitted_software" that references to the software table "u_software".
If a user selects any software from the "user_submitted_software" variable list, it should then verify whether, on that particular software record in the "u_software" table, another checkbox field named "u_additional_justification" is set to true. If it is set to true, then another variable I created should be displayed on the form, named "additional_justification_requirements". If false, the form remains unchanged.
Please note that the "user_submitted_software" variable is empty by default on the form, and the "additional_justification_requirements" variable should be hidden by default(at moment is not). It should only become visible if the software selected in the "user_submitted_software" variable has the "u_additional_justification" checkbox set to true in the backend on the "u_software" table.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 07:52 AM - edited ‎02-22-2024 07:53 AM
@Anirudh Pathak Hi, I got it working by only using a catalog client script, thanks for your help anyway, here is what I did:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 05:45 AM
You'll want an onChange client script on the user_submitted_software field that sends the current value (which will be a comma separated list of the sys_ids) to a server side script (script include function on the script include that is marked client callable). You'll use glideAjax in your client script to send the current value of the field to the server side, and on the server side you will query the software where the sys_id is one of the ones chosen and u_additional_justificastion is true. If it finds any records, then return true, otherwise return false. Then in the client script callback, you'll trigger a show/hide for your additional field on that response. The glideAjax documentation will help guide you: https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideAjaxAPI?navFilter=ajax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 06:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 06:01 AM - edited ‎02-22-2024 06:13 AM
Hi @cicgordy ,
Set variable "additional_justification_requirements" as hidden from variable record itself.
Please use the below code -
On change of User submitted software Catalog Client script -
var software = g_form.getValue('user_submitted_software');
var submittedSoftware= new GlideAjax('script_include_name');
submittedSoftware.addParam('sysparm_name','getData');
submittedSoftware.addParam('sysparm_software',software);
submittedSoftware.getXMLAnswer(getSoftware);
function getSoftware(response){
if(response == 'yes') {
g_form.setDisplay('additional_justification_requirements',true);
}
else {
g_form.setDisplay('additional_justification_requirements',false);
}
}
Script Include -
getData: function() {
var id= this.getParameter('sysparm_software');
var ans = 'no';
var software= new GlideRecord('u_software');
software.addQuery('sys_id',id);
software.query();
if(software.next()) {
if(software.u_additional_justification== true) {
ans = 'yes';
}
}
return ans;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2024 06:40 AM - edited ‎02-22-2024 06:42 AM
Hi @Anirudh Pathak ,
unfortunately didn't work, giving me "There is a JavaScript error in your browser console" message