UI Page not running processing script

grosch
Mega Expert

In my UI Page I've stuck this line to create the ok and cancel buttons:

<g:dialog_buttons_ok_cancel ok="return makeChanges()" ok_type="button" cancel_type="button" />

I then have this in the client script window:

function makeChanges() {

      var service = gel("service").value;

      if (!service) {

              alert("Please select a service to update.");

              return false;

      }

      GlideDialogWindow.get().destroy(); //Close the dialog window

      return true;

}

When I hit OK, the window just goes away.   The code that I have in the Processing script never runs.   Is it because I listed an "ok" callback?   Basically I need to make sure the input is OK and then if it is do the work server side.

16 REPLIES 16

Thijs Daemen
Mega Guru

You don't need to destroy the window when clicking the OK button. I think it's only necessary if you return false, but I don't see a function that you have defined for the cancel button.



try it after removing the line:


GlideDialogWindow.get().destroy(); //Close the dialog window


If you don't destroy the window, it doesn't go away.


It works perfectly without it for me, you only need it on the cancel button function.



I set up a small test so I create a ui page called "ui_page_test".



Jelly:


<?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>


            <input id='testid' type='text'></input>


            <input id="service" value="this is a service" type="hidden"/>


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


  </g:ui_form>


</j:jelly>



Nothing fancy, just a simple form. I assume you have the <g:ui_form> tags?



Client script:


function makeChanges() {  


      var service = gel("service").value;


      if (!service) {  


              alert("Please select a service to update.");  


              return false;  


      }  


      return true;  


}



Processing script:


gs.log('test log');


response.sendRedirect("incident_list.do");



Called from a UI action on the incident form (client checkbox checked and onclick is makeItRun()):


function makeItRun(){


  var dialog = new GlideDialogWindow("ui_page_test");


  dialog.setTitle("This is a test ui page dialog window");


  dialog.render();


}


I tested your code and it works, however I need to retrieve a value from within the client script to process in the processing script.   If I read this correctly I need to return the value back to the HTML and then retreive from that point.   Is this correct.


adamdnock
Mega Contributor

Hi Scott



I had the same problem just now, but tracked it down to the line



              <g:dialog_buttons_ok_cancel ok="return makeChanges()" ok_type="button" cancel_type="button" />



The ok_type and cancel_type attributes seem to break processing script actions



Remove these attributes as such



              <g:dialog_buttons_ok_cancel ok="return makeChanges()" ok_type="button" cancel_type="button" />



And off she goes