sc_task work note is mandatory on closed state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 02:24 PM
Hi all - I have been looking through the wiki to find some help with this.
I have sc_tasks that I want to make work note mandatory when state changes to "closed complete" or "closed incomplete".
I created a ui_policy called "Make work note mandatory on close state". But when I clicked on the "Close Task" button, the ui_policy didn't work.
Do I need to create a business rule or ui action around the "Close task" button. If so, can someone give me some direction on how to do so?
Thanks much!
Hank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 04:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 10:00 PM
state onChange Client script will work for this if you are changing state using state variable but if you are closing the task using Close Task button then you need a before update business rule having following type of code
Condition: current.state.changesTo(7) && current.work_notes="" // 7--->Complete
check the Abort Action check box
Script: gs.addErrorMessage("Work Notes Are Mandatory When Closing Task"); //Or you could specify the message in add message box

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 10:34 PM
Hi Hank,
You can convert the UI Policy to the data policy and it should work in this case. You will find the related link "Convert UI policy to data policy" in the UI policy you have created.
Please let us know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2015 10:37 PM
As per your requirement, I believe that you may want to make the comments field as of mandatory whenever an ui action (Close Task) being clicked upon. So you may modify the code a bit in to your existing ui button to let both of the server side code (that would make your tasks as closed completed after validating the client side checks i.e making the additional field as of mandatory) and client side code (that would mark the comments field as mandatory if the additional field is empty) execute.
You may try the below solution -
script code -
//Client-side 'onclick' function
function closecatalogTask(){
if(g_form.getValue('comments') == ''){
//Remove any existing field message, set comments mandatory, and show a new field message
g_form.hideFieldMsg('comments');
g_form.setMandatory('comments', true);
g_form.showFieldMsg('comments','Comments are mandatory when closing a task.','error');
return false; //Abort submission
}
//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')
closeTask();
function closeTask(){
//Set the 'State' to 'Active', update and reload the record
current.state = 3;
current.update();
gs.addInfoMessage('Task ' + current.number + ' has been closed.');
action.setRedirectURL(current);
}