How to create a user input pop up window?

omsa1
Kilo Guru

Hi All,

I have a requirement when a HRcase reopened,   user have to enter reason for reopening the case. When user click on "Reopen case" UI action it should pop up a window for user to enter reason for reopening (should have an "ok" or "cancel" button in that window) and when user click ok it should check if the input box is empty and add that comment into Comment field , change the case state to work in progress and save. if user click cancel then it should return to current page. Comment shouldn't be empty.

21 REPLIES 21

you mean add this to client script?


Sorry, Not on Client script add this on UI Action.



Like this -


function commentsDialog() {
      //Get the values to pass into the dialog
      var comments_text = g_form.getValue("comments");
      var short_text = g_form.getValue("short_description");

      //Initialize and open the Dialog Window
      var dialog = new GlideDialogWindow("task_comments_dialog"); //Render the dialog containing the UI Page 'task_comments_dialog'
      dialog.setTitle("Add Task Comments"); //Set the dialog title
      dialog.setPreference("comments_text", comments_text); //Pass in comments for use in the dialog
      dialog.setPreference("short_text", short_text); //Pass in short description for use in the dialog
      dialog.render(); //Open the dialog
}


//Setting State as "Work in Progress"


if(current.additional_comments.changes())


current.state = '18';


current.update();


No its not working.


Share your UI Action Script.


Hi Nayan,



Here you go. but i'm thinking onclick will call the commentDialog function and this function will call the add_comments_dialog and once click ok it will call the validate comment function. Since, the if(current.description.changes()) is out of commentDialog function, its not being executed.



UI action script :



function commentsDialog() {


   


  // Get the values to pass into the dialog


    var comments_text = g_form.getValue("comments");


    var short_text = g_form.getValue("short_description");



  // Initialize and open the dialog


  var dialog = new GlideDialogWindow("add_comments_dialog"); //Instantiate the dialog containing the UI Page 'add_comments_dialog'


    dialog.setTitle("Provide reason for reopening this case :"); //Set the dialog title


  dialog.setSize(750,300);


  dialog.setPreference("comments_text", comments_text); //Pass the comments into the dialog


dialog.setPreference("short_text", short_text); //Pass in a short description for use in the dialog


  dialog.render(); //Open the dialog


}



if(current.description.changes())


current.state = '18';


current.update();



=======================================================================



HTML script:



<g:ui_form>


  <!-- Get the values from dialog preferences -->


  <g:evaluate var="jvar_short_text"


      expression="RP.getWindowProperties().get('short_text')" />


  <g:evaluate var="jvar_comments_text"


      expression="RP.getWindowProperties().get('comments_text')" />


    <!-- Set up form fields and labels -->


    <table width="100%">


        <tr id="description_row" valign="top">


              <td colspan="2">


                    <!-- Short description value used as a label -->


                    ${jvar_short_text}


              </td>


        </tr>


        <tr>


            <td>


                <!-- Comments text field (Contains comments from originating record as a default) -->


                <g:ui_multiline_input_field name="dialog_comments" id="dialog_comments" label="Additional comments"


                      value="${jvar_comments_text}" mandatory="true" />


            </td>


        </tr>


        <tr>


            <td colspan="2">


            </td>


        </tr>


        <tr id="dialog_buttons">


              <td colspan="2" align="right">


                    <!-- Add OK/Cancel buttons. Clicking OK calls the validateComments script -->


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


              </td>


        </tr>


  </table>


</g:ui_form>



==================================================================================



Client script :



function validateComments() {


    //This script is called when the user clicks "OK" in the dialog window




    //Make sure there are comments to submit


    var comments = gel("dialog_comments").value;


    comments = trim(comments);


    if (comments == "") {


          //If comments are empty, alert the user and stop submission


          alert("Please enter your comments before submitting.");


          return false;


    }


    //If there are comments, close the dialog window and submit them


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


    g_form.setValue("description", comments); //Set the "Comments" field with comments in the dialog


  g_form.setValue("state", '18');


  gsftSubmit(gel('sysverb_update_and_stay'));


}