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

zica
Giga Guru

Are you working on incident form ? or another form ?


s_kumar
Mega Contributor

thanks Zic..



I am working on incident form ,,


but its not changing the state



FYI...



i have created a table which is in different Application ... and there only i have created this UI Action on Table 'incident'   to change the state but its not working.


..


in last reply to Arnab i have sent my full code...


Hi Sandeep,



I believe it is because the value of the "State" field in the incident table is "incident_state" and not "state" which you are using in this line :


current.state = '2';


use current.incident_state = 2 ;   this will work I am sure. this is also mentioned in the code i have posted for my Reopen Incident button. See the screenshot.



Please let me know if your problem still persists.



Thanks,


Arnab



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


Hi Sandeep,



Did you try my solution of changing the line current.state = '2' ; to current.incident_state = 2 ;       ???


Let me know your result on trying this line with my code.



Thanks,


Arnab




s_kumar
Mega Contributor

yeah   Arnab...



i have tried this also ..but its not changing the state...



after solution Zic gave latest one ...i am able to execute it but its opening new incident instead of changing the state of existing one.