Regaridng UiPage and UiAction in servcienow

LokeshwarRV
Tera Contributor

I have a Requirement Regarding Ui Page and Ui Action
But is Not working correctly
Ui Page

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">

    <div class="form-group form-horizontal">
        <div class="col-md-4 text-right">
            <g:form_label>
                ${gs.getMessage('Choose ITSLT')}
            </g:form_label>
        </div>
        <div class="col-md-8">
            <g:ui_reference name="itslt_ref_field" query="active=true" table="sys_user" />
        </div>
    </div>

    <g:dialog_buttons_ok_cancel ok="return validateOwner()" />

</j:jelly>

and my UI ACtion is 
var gDialogX;

function addITSLTOwner() {
    var prequest = g_form.getUniqueValue();
    // var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
    gDialogX = new GlideModal("dialog_add_item");  
    gDialogX.setPreference('prequest', prequest);
    gDialogX.setPreference('table', 'add_itslt_owner');
    gDialogX.setTitle('Add ITSLT Owner');
    gDialogX.render();
}

function validateOwner() {
    alert("Nikhitha");
    var itslt = $("itslt_ref_field");
    alert(itslt.value);
    g_form.setValue('u_htas_itslt_owner',itslt.value);
    gDialogX.destroy();
    return false;
}

and it not displaying the alert message and in console also it displaying some error msg
validate owner is notdefined



1 ACCEPTED SOLUTION

@LokeshwarRV 

Hope you are doing good.

Did my reply answer your question?

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

View solution in original post

3 REPLIES 3

J Siva
Tera Sage

Hi @LokeshwarRV 
What is your requirement?
Are you trying to open the UI page when someone clcks the UI action?
Regards,
Siva

 

Ankur Bawiskar
Tera Patron
Tera Patron

@LokeshwarRV 

your script is wrong. validateOwner function should be within UI page and not in UI action

try this and it will give you alert

HTML:

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">

  <div class="form-group form-horizontal">
      <div class="col-md-4 text-right">
          <g:form_label>
              ${gs.getMessage('Choose ITSLT')}
          </g:form_label>
      </div>
      <div class="col-md-8">
          <g:ui_reference name="itslt_ref_field" query="active=true" table="sys_user" />
      </div>
  </div>

  <g:dialog_buttons_ok_cancel ok="return validateOwner()" />

</j:jelly>

Client Script:

 function validateOwner() {
      alert("Nikhitha");
      var itslt = document.getElementById('itslt_ref_field');
      if (itslt) {
          alert(itslt.value);
          // Use GlideAjax or g_form from parent if required, else send value to server or return as dialog result
          // Example: pass back the value
          // window.opener.g_form.setValue('u_htas_itslt_owner', itslt.value); <--- only works in popups, not GlideModal
          return true;
      } else {
          alert('Could not find ITSLT field');
          return false;
      }
  }
 

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

@LokeshwarRV 

Hope you are doing good.

Did my reply answer your question?

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