Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

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

it shows the error msg if close notes is empty but it doesn't close the change , it goes to the previous page and if you again click on the record, you don't see any differences.


Check the system logs, as I think you will find an error or warning there that will give you the clue you need



-Jon


Sent from my iPhone


shloke04
Kilo Patron

Hi,



Update the state value in Server side in quotes and try your code again:



current.state = '3';


current.update();



Hope this helps. Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke