A simple way to show a ServiceNow Modal for editing

Can be used to create e.g. related record

Create a UI action and enter at least following:

(Insert/Update=checked,client=checked,Onclick=openModalForm(),form button=checked)

//Show modal with a view (form) for xxx table
function openModalForm() {
    var modalForm = new GlideModalForm('Title' /*Name the modal Title*/ , 'task' /*Table for the new record*/ );

function formOnLoadCallback() {
    //Access GlideModal g_form to set field for the new record
    var d_form = window.frames["dialog_frame"].g_form;
    d_form.setValue('field', g_form.getValue('field'));
    d_form.setValue('field', g_form.getValue('field'));

function formAfterSubmitCallback(action_verb, sys_id, table, displayValue) {
    //Get the newly created record sys_id and then set e.g a value to the starting record
    g_form.setValue('field', sys_id);
    //Save the record

Tested in Jakarta with patch 7

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *