Close task UI Action

sonita
Giga Guru

Actually the close task button on mu change task form   , does not close the task   ,

the requirement is when the state is closed complete and before closing the task form , the close notes field should be mandatory--> ( which is working) but the part that is not working is ---> it doesn't close the task , when hitting the close task button , the form goes to previous page and the state remain the one which was before. This is my code:

function checkwn(){

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

  g_form.setMandatory('close_notes',true);

              alert('Please fill in the mandatory fields');  

}

else{

  gsftSubmit(null, g_form.getFormElement(), 'CheckValue');

}

}

if(typeof window == 'undefined')  

saveValue(); // call Server code  

function saveValue(){  

current.state = 3;

current.update();

action.setRedirectURL(current);  

}

1 ACCEPTED SOLUTION

preddy
Kilo Guru

Hi Try this,



// Client side onclick function


function closeTask(){


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


              try {


                      g_form.hideFieldMsg('close_notes');


              } catch(e) {}


              g_form.setMandatory('close_notes', true);


              g_form.showFieldMsg('close_notes', getMessage('Please enter supporting close notes when closing the change task'), 'error');


              return false;   // Abort submission


      }


      gsftSubmit(null, g_form.getFormElement(), 'closeTaskForm'); //call action name


}


if (typeof window == 'undefined')


    closeChange();



function closeChange {


      current.state = 3;


      current.update();      


      gs.addInfoMessage(gs.getMessage(current.number + " Change Task was successfully completed"));


      action.setRedirectURL(current);


}



Please mark this post Helpful, Like it, or mark as the Correct Answer where applicable. Thanks!


View solution in original post

7 REPLIES 7

Bharath40
Giga Guru

Hi,



Try this code and see if this works , make sure Action name is same


function checkwn(){


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



  g_form.setMandatory('close_notes',true);


              alert('Please fill in the mandatory fields');


return false;


}


  gsftSubmit(null, g_form.getFormElement(), 'CheckValue') /Check value must be same as Action Name



}


if(typeof window == 'undefined')


saveValue(); // call Server code




function saveValue(){


current.state = 3;


current.update();


action.setRedirectURL(current);


}


No change! it goes to previous page without any changes


Jon Barnes
Kilo Sage

Check the system logs for errors or warnings. I have found that if you have set the UI action to stay on the current form but it still exits, it is hitting an error condition and not completing the ui action code. The logs should give you the clue you need to solve it.



click the close task button and then look for warnings or errors created by your ID in the logs.


preddy
Kilo Guru

Hi Try this,



// Client side onclick function


function closeTask(){


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


              try {


                      g_form.hideFieldMsg('close_notes');


              } catch(e) {}


              g_form.setMandatory('close_notes', true);


              g_form.showFieldMsg('close_notes', getMessage('Please enter supporting close notes when closing the change task'), 'error');


              return false;   // Abort submission


      }


      gsftSubmit(null, g_form.getFormElement(), 'closeTaskForm'); //call action name


}


if (typeof window == 'undefined')


    closeChange();



function closeChange {


      current.state = 3;


      current.update();      


      gs.addInfoMessage(gs.getMessage(current.number + " Change Task was successfully completed"));


      action.setRedirectURL(current);


}



Please mark this post Helpful, Like it, or mark as the Correct Answer where applicable. Thanks!