How to render a dialog box based on a condition

saranyadevic
Kilo Contributor

Hi all,

I have created a glide dialog window which will get input and update the record,

Now i need to show the input field when another field of a table is holding a particular value else it should throw error,

client checked

UI action   :

function updateIncidentDetails() {

var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;

//Initialize and open the dialog

var gDialog = new GlideDialogWindow("alert_incident_window");//Instantiate the dialog containing the UI Page 'alert_incident_window'

gDialog.setTitle("Enter incident details");

gDialog.setPreference('sysparm_sysID', sysId);

gDialog.setPreference('sysparm_table', "em_alert");

gDialog.render();//Open the dialog

}

The above Ui action will get the incident id value in a text box and update it in the remote task id,     along with the UI page

I need to display the dialogue box only if the   another field has desired value

consider u_fieldname == 1

if i add in the condition of UI action   alert is shown   as 'Security does not allow the execution of that action against the specified record'

Instead i need a custom alert message to be populated

Can this be achieved ?

26 REPLIES 26

i checked with the record which contains value   in the particular field, how ever it doesnt enter else condition,   nothing happens on clicking.


Hi Saranya,



what value that record is having for that field. Also can you add screenshot here?



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,



when I unchecked client and used current instead of g_form  



updateSmitStatus();


function updateSmitStatus() {


var value = current.u_lc_flag;


gs.addInfoMessage(value);


if(value == 96){


var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;


//Initialize and open the dialog


var gDialog = new GlideDialogWindow("alert_smit_window");//Instantiate the dialog containing the UI Page 'alert_smit_window'


gDialog.setTitle("Transmission Incident Exist");


gDialog.setPreference('sysparm_sysID', sysId);


gDialog.setPreference('sysparm_table', "em_alert");


gDialog.render();//Open the dialog


}


else {


gs.addInfoMessage('error');


}



}



Im getting the value of the field   as well as   getting inside else part ,but dialog is not opening


Hi Saranya,



The GlideDialogWindow works only on client side and will break in server side.


Can you alert the value of this field 'u_lc_flag' and make the ui action client side.



Is name of your column which you want to check 'u_lc_flag' in the if condition



update your code as follows:



function updateSmitStatus() {



alert('alert value of field u_lc_flag is:'+g_form.getValue('u_lc_flag'));


Also can you check whether this field is present on the form layout



if(g_form.getValue('u_lc_flag') == 1){


alert('iam in');


}


else {


var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;


//Initialize and open the dialog


var gDialog = new GlideDialogWindow("alert_smit_window");//Instantiate the dialog containing the UI Page 'alert_smit_window'


gDialog.setTitle("Transmission Incident Exist");


gDialog.setPreference('sysparm_sysID', sysId);


gDialog.setPreference('sysparm_table', "em_alert");


gDialog.render();//Open the dialog


}



}



It would be nice if you share the screenshot and will help to resolve this faster.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

uipages.png



Value of Awaiting SMIT check is integer


on clicking that   no action takes plac