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

Hi Saranya,



Can you share the screenshot of the ui action along with the code?



Regards


Ankur


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

smitstatus.png


Hi Saranya,



So what are you getting the value of the field?


If it is 96 then only it will go inside the if condition.



Regards


Ankur


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

value of field is 96 ,   but g_form.getValue('u_lc_flag') is not getting the value



so its getting inside function not inside if condition


Hi Saranya,



So g_form won't get the value if the field is not present on the form layout.


Can you confirm whether the field is present on the form layout?



you can add that field to form layout if currently if it isn't and if required hide it on form load if end user is not supposed to show the field.



Regards


Ankur


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