ui page and glidewindow

ryadavalli
Tera Expert

I have a UI page which I am calling from a client script. The Ui page has 2 buttons Yes and No.

I am calling the UI page from GlideDialogWindow.

I want the to know if the user selected Yes or No.

Ui page (pop_up_yes_no):

<g:ui_form>

      <button id="confirmYes" onClick = "getYes()" type ="button">Yes</button>

      <button id="confirmNo" onClick = "getNo()" type ="button">No</button>

</g:ui_form>

GlideDialogWindow in client script

var gdw = new GlideDialogWindow('pop_up_yes_no', callbackFunct);

              gdw.setTitle('Configuration Item');

              gdw.setSize(750,300);

              gdw.render();

      }

How can get which one user (Yes or No) selected and use them in the call back funtion to set some values on the form ?

1 ACCEPTED SOLUTION

Stephen W_
Giga Guru

You need to bind the responses to yes and no functions:



//UI action


function checkCancel() {


        var cancelIt= function(){


                  //probably do nothing here?


        };


        var doIt= function(){


                  //do something here


        };



        function popMessage() {


                  var gdw = new GlideDialogWindow('pop_up_yes_no');


                  gdw .setTitle('Configuration Item');


                  gdw .setPreference('onYes', cancelIt.bind(this));


                  gdw .setPreference('onNo', doIt.bind(this));


                  gdw.setSize(750,300);


                  gdw .render();


        }
}



//UI page


//HTML


<td class="dialog_buttons">


  <g:dialog_button id="yes" type="button" onclick="invokePromptCallBack('yes');">Yes</g:dialog_button>


<g:dialog_button id="no" type="button" onclick="invokePromptCallBack('no');">No</g:dialog_button>


  </td>



//Client script


function invokePromptCallBack(type) {


      var gdw = GlideDialogWindow.get();


      if (type == 'yes')


              var f = gdw.getPreference('onYes');


      else


              var f = gdw.getPreference('onNo');


      if (typeof(f) == 'function') {


              try {


                      f.call(gdw, gdw.getPreference('oldValue'));


              } catch(e) {


              }


      }


      gdw.destroy();


      return false;


}


View solution in original post

7 REPLIES 7

Stephen W_
Giga Guru

There are two ways to do that.   The most obvious is to bind a yes function to onYes, and a no function to onNo as I described in my original response.("cancelIt" and "doIt"):



Client script:



yesOrNo();


function yesOrNo() {


        var cancelIt= function(){


                  //probably do nothing here


        };


        var doIt= function(){


                  //Set your field values here
                  g_form.setValue("u_my_field","They like that CI");


        };



        var gdw = new GlideDialogWindow('pop_up_yes_no');


        gdw.setTitle('Configuration Item');


        gdw.setPreference('ci', cmdb_ci);//Pass the CI//


        gdw.setPreference('onYes', cancelIt.bind(this));


        gdw.setPreference('onNo', doIt.bind(this));


        gdw.setSize(750,300);


        gdw.render();


}


How can I pass the current record e.g Incident sys Id to a UI page (called by a GlideDialogWindow) ? We need to display a custom form which contains like shipping info (UI page contains the input fields and a submit button) then when user fill outs this it will run the proccessing script that contains a glide record to a custom table and create a new record based on current Incident fields and the custom shipping address that is taken from this UI page, however we don't know how to get the current record sys ID, we already get the values of the imputs to the proccessing script but no luck yet with current rec sys ID


You can use <j:set var="jvar_sys_id" value="${RP.getWindowProperties().get('sys_id')}" /> to grab it.