The CreatorCon Call for Content is officially open! Get started here.

Autopouplate UI page based on selected RITM

Meenal Gharat
Tera Guru

Hello Experts,

 

I want to autopopulate the UI page based on the RITM selection i.e. is a refernce field.

Cost center and Server should be autopopulated from RITM variables.

Below is My UI page.

 

MeenalGharat_0-1760314246403.png

This Ui page should trigger when Change request's state is Review it should Pop up the UI page on change form and click of Okay it should update description with UI page values.

 

Below is my HTML and client script.

HTML:

<?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:ui_form>
    <table>
            <tr>
                  <td style="width:25%">
            <g:form_label>
            RITM-Ref:
                </g:form_label>    
                  </td>
          <td style="width:60%">
            <g:ui_reference name="RITM-Ref:" id="RITM-Ref:" query="cat_item.nameLIKEProject Request^variables.b12dcbd71b496c10537d2069bc4bcbe3=1000" table="sc_req_item" onchange="fetchRITMDetails()"/>
                   </td>
                </tr>

        <tr>
        <td style="width:25%">
            <g:form_label>
            Name of the Onboarded Server
            </g:form_label>
                 </td>
        <td style="width:60%">
                 <input type="text" aria-label="Name of the Onboarded Server" name="server_name" id="server_name" maxlength="25"/>  
                </td>
        </tr>
        <tr>
                   <td style="width:25%">
            <g:form_label>
            Cost center:
            </g:form_label>
                   </td>
            <td style="width:60%">
                     <input type="text" aria-label="Cost Center" name="cost_center" id="cost_center" maxlength="25"/>  
                    </td>
                </tr>
        <tr>
                     <td>
                       <g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
                    </td>
               </tr>
    </table>
    </g:ui_form>
</j:jelly>


Client Script :
function continueOK() {
    alert("OK clicked");
    var gdw = GlideDialogWindow.get();
    var name =gel('server_name').value;
    var user = gel('RITM-Ref:').value;
    var costcenter = gel('cost_center').value;
        var sys_id = gdw.getPreference('sys_id'); //get the values passed in the client script
    var selected_value = gdw.getPreference('value'); //get the values passed in the client script
    alert(name+"---"+user+"---"+cat+"---"+sys_id+"---"+selected_value);
    GlideDialogWindow.get().destroy();
}
function continueCancel() {
    alert("Cancel clicked");
    GlideDialogWindow.get().destroy();
}
Processing script :
var user = request.getParameter("RITM-Ref:"); //mention the name of the elment here
var server_name = request.getParameter("server_name"); //mention the name of the elment here
var cost_center = request.getParameter("cost_center"); //mention the name of the elment here
 
How can I autopopulate and trigger this page on change request?
 
Best Regards,
Meenal 

 

1 REPLY 1

kaushal_snow
Mega Sage

@Meenal Gharat ,

 

 

you can do it, use a client script (onChange of the RITM ref field or via UI Action) to get the RITM sys_id, then call something like:

var dialog = new GlideDialogWindow('your_ui_page_name');
dialog.setPreference('ritm_sys_id', g_form.getValue('ritm_ref_field'));
dialog.render();

Inside the UI Page Jelly you grab the sys_id via RP.getWindowProperties().get('ritm_sys_id'), query sc_req_item and its variables via Jelly/GlideRecord to set default server_name & cost_center values, then let the OK button return values back to form via client script in UI Page which sets g_form.setValue on the original form fields....

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/