The CreatorCon Call for Content is officially open! Get started here.

Close Task button assistance

Cupcake
Mega Guru

I have created a client script that will make certain fields on my form mandatory when the state of the Task change to either Close Complete or Closed Incomplete. But upon testing I noticed that if I click the close task button while the state is Open or Work in Progress - it will Close the Task and never make those fields mandatory and stop the task from being closed. Is there something that I can include in the client script that I currently have.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue == '') {

          return;

    }

     

      var item = g_form.getReference('request_item', doItem);

}

      function doItem(item) {

              if (item.cat_item == '4e6e882f6fe62600512f5e354b3ee4fa' || item.cat_item == '026755ff6f62260055b71702be3ee433' || item.cat_item == '4f907df76fa2260055b71702be3ee4c8') {

                      if (g_form.getValue('state') == 3 || g_form.getValue('state') == 4) {

                              g_form.setMandatory('type_of_effort', true);

                              g_form.setMandatory('assigned_priority', true);

                              g_form.setMandatory('trgt_release_date', true);

                              g_form.setMandatory('assign_to', true);

                      }

                      else {

                              g_form.setMandatory('type_of_effort', false);

                              g_form.setMandatory('assigned_priority', false);

                              g_form.setMandatory('trgt_release_date', false);

                              g_form.setMandatory('assign_to', false);

                      }

              }

      }

     

find_real_file.png

find_real_file.png                   find_real_file.png

Thanks,

Karen

4 REPLIES 4

anurag92
Kilo Sage

Client script is monitoring the change on State field and based on that it is making fields mandatory.



Ui action for closing has Server side code, to close the task, and does not monitor the state field at all. I guess, you need to create an onLoad client script, which checks if state is closed, and based on that make fields mandatory.



Let me know if that helps.


dvp
Mega Sage

I think the server event is overriding the client script functionality.


Why don't you use the UI action and with client side functionality in it


I was able to utilize the Close Task UI Action that was already in place and modify the script for the action to change the state to Closed Complete if the user clicks the Close task button.



Just by adding this little bit to the script.


if (state == '1' || state == '2') {


    g_form.setValue('state', '3');


}


swati38
Tera Expert

HI Karen,



Kindly modify your UI Action.


I have a similar scenario in the change task form,the close task button was changing the state of the change task irrespective of the mandatory filed (in my case 'description' field). so I had dome modifications to the code as shown below.


refer to the below code :


function clic()


{


var a= g_form.getValue('description');


      if(a==false)//validate all the conditions


      {


        g_form.setMandatory('description',true);


      }


else {


      g_form.setValue('state',' ');}



gsftSubmit(null, g_form.getFormElement(),'test');} //test is my action name



if(typeof window=='undefined') {


sersid();


}


function sersid()


{


current.state=3;


current.update();


gs.addinfoMessage('success');


}