Close Task button assistance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 05:00 AM
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);
}
}
}
Thanks,
Karen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 05:05 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 06:45 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 11:59 AM
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');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 05:29 AM
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');
}