- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 04:49 AM
Hey Garfield -
My post on 06-21-2017 at 9:32am pretty much sums up the solution we developed. It has 2 parts that work together. First, a display business rule that runs on insert and update. The business rule just captures time worked and sets a g_scratchpad variable to the value of time worked before the form is opened. The script for that business rule is below. You will need this business rule on the Task table (or whatever task types you want to make time worked mandatory):
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.time_worked_inc = current.time_worked.dateNumericValue();
///gs.log('time: '+ current.time_worked.dateNumericValue(),'time');
})(current, previous);
The second part is an onSubmit client script that checks to see if there was any time entered and throws an alert message if not. You’ll either need one of these on your Task table or on the specific task types you want time worked to be mandatory on. Below is the onSubmit Client Script. We have it only running on certain action types (when someone saves or updates). There are other actions people can take on forms that are not save or update, and we only want to check if they entered time when they’re saving or updating the form:
function onSubmit() {
///get the value of time worked as the user tries to update/save thee form
var timer = g_form.getIntValue('time_worked');
//multiply time worked integer value by 1000
var dateNumeric = timer * 1000;
//get the name of the action the user is performing, we only want to prevent someone from updating or saving if there is not time worked
var action = g_form.getActionName();
//if the user's action is update or save, make sure they entered time worked, and if not, prompt an alert message
if (action == 'sysverb_update' || action == 'sysverb_update_and_stay'){
var diff = dateNumeric - g_scratchpad.time_worked_inc;
if(diff == 0){
alert('Please enter Time Worked before updating Incidents. Thank You.');
return false;
}
The only real lesson learned that i can share is that this was a temporary solution for our organization. It was in place for a year or two and then we deactivated it as the organization evolved. It worked well for us at the time. I'd just make sure to only place it on the task tables that you are targeting to be mandatory. If you put it on the core Task table you might be surprised how many tables extend it where you don't care about time worked, and will have to go back and add exceptions.
Let me know if you have further questions.
Thanks,
Taylor