Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Dialog box issue

SG23
Tera Expert

Hi Guys, I have an ask to show dialog box (as below, where if the checkbox inside is selected the buttons submit/cancel to be selected again before record is saved) when a 'location' record is created/updated. Please guide with any example. ThanksTest.png

6 REPLIES 6

TamoghnaB
Tera Expert

Hi @SG23 , 

You need to create a OnSubmit Client Script and an UI Page. The client script will be used to call the UI page which will open in a form of a dialog box.

 

Example:

Client script / Submit button:

function validateAndSubmit() {
var comments = gel('dialog_comments').value;
if (comments.trim() === '') {
alert('Comments are required!');
return false;
}
// Example: Pass data back to the parent form (if applicable)
// var parentForm = parent.g_form;
// parentForm.setValue('description', comments);
GlideDialogWindow.get().destroy(); // Close the dialog
}

 

UI Page:

<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide">
<g:ui_form>
<p>This is a custom dialog!</p>
<g:ui_textarea name="dialog_comments" id="dialog_comments" rows="5" cols="50" label="Comments"/>
<g:dialog_buttons_form>
<g:ui_button onclick="validateAndSubmit()">OK</g:ui_button>
<g:ui_button onclick="GlideDialogWindow.get().destroy()">Cancel</g:ui_button>
</g:dialog_buttons_form>
</g:ui_form>
</j:jelly>

 

 

 

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Ankur Bawiskar
Tera Patron
Tera Patron

@SG23 

what's your actual business requirement to show that modal?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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