
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 06:59 AM
Hi there is a UI action for the Close Task button, the script is set to mark the task Closed Complete upon clicking that button, but I want the task to mark based on the state; therefore IF the state = Closed Complete then when you click the Close Task button the functionality should mark the task as Closed Complete and IF the state = Closed Incomplete then when the Close task button is clicked the functionality should mark the task as Closed Incomplete.
I am having some difficulty in making that happen.
function closeTask(){
if(g_form.getValue('assigned_to') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
g_form.setMandatory('assigned_to', true);
g_form.showFieldMsg('assigned_to','Assigned to is mandatory when closing the task.','error');
return false; //Abort submission
}
g_form.setValue('state', '3');
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_Task'); //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')
serverReopen();
function serverReopen(){
//Set the 'State' to 'Active', update and reload the record
current.update();
action.setRedirectURL(current);
}
Thanks,
Karen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 09:59 AM
You should be able to say:
function closeTask(){
var state = g_form.getValue('state');
if(g_form.getValue('assigned_to') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
g_form.setMandatory('assigned_to', true);
g_form.showFieldMsg('assigned_to','Assigned to is mandatory when closing the task.','error');
return false; //Abort submission
}
if(state == 4) // or whatever your closed incomplete value is
g_form.setValue('state', state);
else
g_form.setValue('state', '3');
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_Task'); //MUST call the 'Action name' set in this UI Action
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2015 07:55 AM
Thank you Mike - I just had a chance to get back to this and it worked perfectly.
Your a life saver.
Have an Awesome Day !

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2015 10:17 AM
Hi Karen,
I agree with Brad here. Can you please elaborate further on your req.