How do I pass values to UI Page with glideModal?

corbettbrasing1
Mega Guru

The API has no examples unfortunately https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideModalClientSideV3API

https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideModalClientSideV3API

I know I invoke GlideModal client side on the form but in the UI page, do I just call get(glideModalStringID)

then use getPreference() in a g2 tag?

1 ACCEPTED SOLUTION

Ok since there are zero example of using Glide modal in the API I am posting my code.   Hopefully we can get a doc update.   https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideModalClientSideV3API



UI ACTION:


Client Callable: Yes


function confirmAndProcess() {//can call this whatever you want


  var message = "TYPE YOUR MESSAGE HERE";



  var confirm = new GlideModal('NAME_OF_UI_PAGE',false, 'modal-lg');
  confirm.setPreference("sysparm_message", message);


  confirm.setTitle("Confirm");


  confirm.render();


}



//Code that runs without 'onclick' function, this will only run if the client script in the UI page runs that recalls the ui action directly with gsftSubmit().   See UI page code


//Ensure call to server-side function with no browser errors


if (typeof window == 'undefined')


  someServerCall();




//Server-side function


function someServerCall(){


  current.setValue("state", 15);


  current.update();


  action.setRedirectURL(current);


}}



UI PAGE 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">



<j:set var="jvar_pref" value="${sysparm_message}"/>




  <div class="modal-body">


  <p>


  ${jvar_pref}


  </p>


  </div>


  <footer class="modal-footer flex">


          <g:dialog_buttons_ok_cancel ok="return onOK();" cancel="return onCancel();" ok_type="button" cancel_type="button"/>




  </footer>


</j:jelly>



UI PAGE CLIENT SCRIPT:


function onOK() {


gsftSubmit(null, g_form.getFormElement(), 'NAME_OF_UI_ACTION'); //MUST call the




}




function onCancel() {


  var o = GlideModal.prototype.get('SCOPE.UI_PAGE_NAME');


  o.destroy();


}


View solution in original post

10 REPLIES 10

Abhinay Erra
Giga Sage

There are many UI pages OOB that uses this API. You can refer any of them. This is how it is called in the client script section. Go to 'clone_confirm' Ui page



This is how it is used


var o = GlideDialogWindow.prototype.get('clone_confirm'); //this is the UI page name


  var f = o.getPreference('onCancel');


Abhinay Erra
Giga Sage

For GlideModal class usage, refer this UI action and UI page


UI action: Move to project


UI page: ppm_int_ref_dialog


I am going to need an example on glidemodal   if you coudl be so kind


Ok since there are zero example of using Glide modal in the API I am posting my code.   Hopefully we can get a doc update.   https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideModalClientSideV3API



UI ACTION:


Client Callable: Yes


function confirmAndProcess() {//can call this whatever you want


  var message = "TYPE YOUR MESSAGE HERE";



  var confirm = new GlideModal('NAME_OF_UI_PAGE',false, 'modal-lg');
  confirm.setPreference("sysparm_message", message);


  confirm.setTitle("Confirm");


  confirm.render();


}



//Code that runs without 'onclick' function, this will only run if the client script in the UI page runs that recalls the ui action directly with gsftSubmit().   See UI page code


//Ensure call to server-side function with no browser errors


if (typeof window == 'undefined')


  someServerCall();




//Server-side function


function someServerCall(){


  current.setValue("state", 15);


  current.update();


  action.setRedirectURL(current);


}}



UI PAGE 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">



<j:set var="jvar_pref" value="${sysparm_message}"/>




  <div class="modal-body">


  <p>


  ${jvar_pref}


  </p>


  </div>


  <footer class="modal-footer flex">


          <g:dialog_buttons_ok_cancel ok="return onOK();" cancel="return onCancel();" ok_type="button" cancel_type="button"/>




  </footer>


</j:jelly>



UI PAGE CLIENT SCRIPT:


function onOK() {


gsftSubmit(null, g_form.getFormElement(), 'NAME_OF_UI_ACTION'); //MUST call the




}




function onCancel() {


  var o = GlideModal.prototype.get('SCOPE.UI_PAGE_NAME');


  o.destroy();


}