- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 06:32 AM
Our display business rule script is very simple. It just captures time worked and sets a g_scratchpad variable to the value of time worked before the form is opened :
(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);
Here is the onSubmit Client Script. We have it only running on certain action types (when someone saves or updates):
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;
}
}
}