Issue with g_form.setMandatory inside client method of UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 02:09 AM
Hi Developers,
All good, but only mandatory for worknotes is not working, please help me where i am going wrong?
Client method inside UI action
function runClientCode2() {
var confirmation = confirm("Are you sure you want to cancel this change?");
if (confirmation != true) {
return false;
}
var num = g_form.getValue("number");
var ga = new GlideAjax('global.ChangeVulDetails');
ga.addParam('sysparm_name', 'getRemTaskDetails');
ga.addParam('sysparm_vulnum', num);
ga.getXML(updateCampus);
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("answer:" + answer);
if (answer) {
g_form.setMandatory('work_notes', true);
alert(" inside true");
}
}
g_form.checkMandatory = false;
gsftSubmit(null, g_form.getFormElement(), 'canceling_change2');
}
Script include which is client callable
var ChangeVulDetails = Class.create();
ChangeVulDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRemTaskDetails:function(){
var vulnum = this.getParameter('sysparm_vulnum');
var grt = new GlideRecord('change_request');
grt.addQuery('number',vulnum);
grt.query();
if(grt.next()){
var pass = grt.parent.getDisplayValue();
if(pass.includes('VUL')){
return true;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 02:14 AM
You should use the g_form to a client side entity (client scripts, UI policies).
Mark Helpful if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 02:42 AM
I am using g_form. setMandtory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 03:10 AM
Did you put alert and check is pass answer returning something? is this alert coming alert(" inside true");?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2022 07:55 PM
Hi, ya that alert is coming. My only guess is this line g_form.checkMandatory = false; is causing issue, as its making all fields which are mandatory to non-mandatory.