- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 12:11 AM
I have a requirement that on the incident form, show a checkbox field - Escalation to only members of the group 'Service Desk' or users having role 'admin'
Also, if the checkbox is set to 'true', make the work notes mandatory, otherwise if the checkbox is false, make work notes non-mandatory.
I have written a script include for group check -
var getSerDeskgroup = Class.create();
getSerDeskgroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myServiceDesk : function()
{
if ((gs.getUser().isMemberOf('Service Desk')) || (gs.hasRole('admin')))
{
return true;
}
else
{
return false;
}
},
type: 'getSerDeskgroup'
});
And the onChange (of Escalation) client script is
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue != '')
{
alert('Escalation is checked ' + newValue);
var ga = new GlideAjax('getSerDeskgroup');
ga.addParam('sysparm_name', 'myServiceDesk');
ga.getXML(parseMember);
}
function parseMember(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true')
{
g_form.setMandatory('work_notes', true);
}
}
if (newValue == false)
{
alert('Escalation is unchecked ' + newValue);
g_form.setMandatory('work_notes', false);
}
}
It seems the functionality is not working as expected
Any help on this will be appreciated.
Thanks in advance!!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 02:53 AM
Below 2 cusomizations should resolve your issue :
1. Wrie an UI policy on incident form as shown below :
2. Write 2 similar ACLs (1 for READ, other for WRITE) as shown below:
I tried this and this resolved the issue. You can try it, and if it works please mark it CORRECT answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 12:23 AM
Put gs.log in Script include and alert 'answer' in client script to see what is being returned...
let me know what you get in log and alert .
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 12:24 AM
HI Kunal,
Steps:
1. Create a Display Business Rule on Incident table with the below line,
g_scratchpad.isValidUser= new getSerDeskgroup().myServiceDesk();
2. Modify the client script to something like below,
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading) {
- if(g_scratchpad.isValidUser=='true')
- {
- g_form.setDisplay('escalation', true)
- }
- else{
- g_form.setDisplay('escalation', false)
- }
- } else{
- if (newValue == true)
- {
- g_form.setMandatory('work_notes', true);
- }
- if (newValue == false)
- {
- g_form.setMandatory('work_notes', false);
- }
- }
- }
Thanks
Srinivas
Mark this response as helpful/correct if it does so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 12:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 01:10 AM
Hi Kunal,
You can use your earlier approach..
Just change the onChange CS as below:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading && newValue=='false' ) {
return;
}
if (newValue == 'true')
{
alert('Escalation is checked ' + newValue);
var ga = new GlideAjax('getSerDeskgroup');
ga.addParam('sysparm_name', 'myServiceDesk');
ga.getXML(parseMember);
}
else
{ alert('Escalation is unchecked ' + newValue);
g_form.setMandatory('work_notes', false);
}
function parseMember(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true')
g_form.setMandatory('work_notes', true);
}
}
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.
Thanks,
Deepa