How to call GlideDialogWindow from client script of another ui page

Pooja Mahamuni
Tera Contributor

Hi,

 

I have created one button UI action on form. When we click on button then dialog box opens up which has Cancel and Submit button. Till here everything is working fine. Now when we click on Submit button, another dialog box should open which also need users confirmation asking "do you want to Add or replace" which has 2 buttons "Add" or "Replace". Is there any way to achieve it?

 

Thanks

Pooja

7 REPLIES 7

Hi Ankur,

 

Requirement is:

I have UI action on form named "Copy Record". When user click on this button first dialog box should be shown which has project reference field and "Submit" and "Cancel" button. When we select the project
record in that field I have to check if particular type of record is already present to the selected project record. If the record is present then I want to show second dialog
box on same page saying, "The record of this type "xyz" is already present do you want to replace it or add it" which has 2 buttons "Add" and "Replace".

If user click on Add then new record should be created and if he selects Replace then old one should deleted and new should create and attached to that selected project record.

 

Please let me know if this is possible or not

@Pooja Mahamuni 

Why not use single UI page and show a drop down with 2 options Add/Replace

Let user select the Project and the option and then based on that handle the logic

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

Hi Ankur,

As soon as user select the project in reference field of ui page then I want to show the message on the same confirmation window that "The record of this type "xyz" is already present to the project do you want to replace it". And one check box will be shown on same dialog window based on if record is already present (should be present in related list of project) for selected project. so user can give input via that checkbox. And then user can click submit or cancel.

 

I am struggling how to check the record of selected project in HTML of ui page. Could you please help me with the code:

 

Here is my HTML  code:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:requires name="SPMGmodalIframeMsgHelper.jsdbx" includes="true"/>
<g:ui_form>
  <input type="hidden" name="name" value="link_existing_change_to_project_task"/>
  <input type="hidden" id="cancelled" name="cancelled" value="false"/>
  <input type="hidden" id="formSource" name="formSource" value="${sysparm_form_source_name}"/>

  <g:evaluate jelly="true">
     var parent_task = jelly.sysparm_sysID;
     var table_name = "task";
  </g:evaluate>
    <input type="hidden" name="parent_task" id="parent_task" value="${sysparm_sysID}"/>
    <div class="form-horizontal" id="link-change">
        <span> Use the lookup icon to display project records</span>
        <div class="row link-change-modal-row ${sysparm_form_source_name}" style="margin-top:20px;">
            <div class="form-group is-required" id="ref_change_request">
                <div nowrap="true" type="string" choice="0" data-type="label">
                    <label class="col-sm-12 col-md-3 control-label" for="sys_display.document_key">
                        <span class="label-text">Project</span>
                    </label>
                </div>
                <div class="form-field col-sm-12 col-md-6 input_controls">
                    <g:ui_reference name="document_key" id="document_key" table="${table_name}" query="sys_class_name=pm_project^active=true"/>
                </div>
            </div>
        </div>
        <div id="dialog_buttons" style="text-align:right;padding-top:20px;">
            <g:dialog_buttons_ok_cancel ok="return onSubmit()" cancel="return onCancel()"/>
        </div>
    </div>
</g:ui_form>
<div class="load_mask_container" style="display:none;">
    <span class="icon icon-loading"></span>
</div>
</j:jelly>