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

Hie Sarasaamani,



Refer this for setting size of window box.


GlideDialogWindow API Reference - ServiceNow Wiki


Hi Nayan,


its working but i have another problem now.Hope someone can help.



when i reopen a hr case , add comment and save , it's changing the state from Resolved to "work in progress" and saving the comment from pop up box. But when i impersonate a end user and tried to reopen a case, its just updating the comment but not changing the state to work in progress. Is it due to my admin access?



find_real_file.png



in the 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 "description" field with comments in the dialog


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


  g_form.save();


}


Check ACL Is restricting users to update that field.


This is the ACL which restrict end users to update "STATE" field -


hr_case.PNG


Hi Nayan,



You're right, ACL is the one controlling the state. However, initially they were able to change the state with the UI action script below. Is there any way for me to add this into Validatecomment() client script?   cause when i add this into script, its not saving the comment or changing state. can't use UI action script in client script?




new StateFlow().processFlow(current, 'c77bfec04f682200143327201310c7d7', 'manual');


current.state = '18';


current.update();


action.setRedirectURL(current);


Hey,



You can update state field after the function on UI Action like this -


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 "description" field with comments in the dialog


  g_form.save();


}



//Setting State as "Work in Progress"


if(current.additional_comments.changes())


current.state = '18';


current.update();