can someone help me to userstand UI action how its working client and server side together with example ..?

s_kumar
Mega Contributor

Request

1 ACCEPTED SOLUTION

zica
Giga Guru

Okay perfect,



Here is a screenshot that shows the parameters of the UI action, Please do the same


Do not forget to put the action name, check client to true, and put the function name on Onclick()


Capture d



HEre is the script :



function reopenIncidentTest(){


     


      if (g_form.getValue('comments') == '') {


              //Remove any existing field message, set comments mandatory, and show a new field message


              try {


                    g_form.hideFieldMsg('comments');


              } catch(e) {}


                    g_form.setMandatory('comments', true);


                    g_form.showFieldMsg('comments','Reason is required when reopening an incident','error');


                      return false;   //Abort submission


        }


      //Call the UI Action and skip the 'onclick' function


      gsftSubmit(null, g_form.getFormElement(), 'incident_reopen_test'); //MUST call the 'Action name' set in this UI Action


}



//Code that runs without 'onclick'


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



if (typeof window == 'undefined')


      serverReject();



function serverReject(){


      current.state = 2;


      current.update();


}


View solution in original post

31 REPLIES 31

Sandeep,



I found that Zic in his latest reply left out this line (though not intentionally) : action.setRedirectURL(current);


You have to use this line to be redirected to the current incident you want to reopen. See the position of the line in my code and place this to achieve your desired result.



Thanks,


Arnab




Please mark Correct/Helpful according to the worthiness of my solution.


s_kumar
Mega Contributor

Hi Arnab I have tried this but still it is opening the new incident not the existing one.


What exact lu You mean by it is opening a new incident ? You mean by while clicking on that button, another incident is getting updated ? Or it is redirecting you to another resolved incident ?



Let's say take the resolved incident INC00001, fill out the Comment field, click on that reopen incident button and what's happening ?


If you search INC00001 within your incident list, what is the state ?


zica
Giga Guru

Okay perfect,



Here is a screenshot that shows the parameters of the UI action, Please do the same


Do not forget to put the action name, check client to true, and put the function name on Onclick()


Capture d



HEre is the script :



function reopenIncidentTest(){


     


      if (g_form.getValue('comments') == '') {


              //Remove any existing field message, set comments mandatory, and show a new field message


              try {


                    g_form.hideFieldMsg('comments');


              } catch(e) {}


                    g_form.setMandatory('comments', true);


                    g_form.showFieldMsg('comments','Reason is required when reopening an incident','error');


                      return false;   //Abort submission


        }


      //Call the UI Action and skip the 'onclick' function


      gsftSubmit(null, g_form.getFormElement(), 'incident_reopen_test'); //MUST call the 'Action name' set in this UI Action


}



//Code that runs without 'onclick'


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



if (typeof window == 'undefined')


      serverReject();



function serverReject(){


      current.state = 2;


      current.update();


}


s_kumar
Mega Contributor

thak you Zic...!!



i am not feeling Shy ..



i have implemented your code ..but when i am clicking that button its opening new incident not the same with changing state to Active..