Issue with g_form.setMandatory inside client method of UI action

Gayathri5
Tera Guru

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;

}
}

 

4 REPLIES 4

GodOfWar
Mega Guru

You should use the g_form to a client side entity (client scripts, UI policies).

 

Mark Helpful if this helps.

I am using g_form. setMandtory

Saurav11
Kilo Patron
Kilo Patron

Did you put alert and check is pass answer returning something? is this alert coming alert(" inside true");?

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.