- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2017 06:32 AM
Thank you for the reply Vamsi. Looking at your solution it looks like it would definitely work for what we were trying to do. This is what we ended up doing for our solution:
Created a 'Display' business rule and onSubmit Client Script on each table we wanted time worked to be mandatory on. The Display business rule captures time worked on form open. Using g_scratchpad functionality, we passed the value of time worked on open to an onSubmit client script. The onSubmit client script captures the original time worked using g_scratchpad, compares it to the original time worked, and prevents submission if time didn't increment by more than 0.
I can post the code if someone is interested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2017 12:39 AM
ya pls post it i can use as reference.
thank you.
- 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;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2023 09:12 AM
Hi Tslogue,
Our organization have the same issue and I am tasked with finding a solution. A review of what you did seem to be what I am looking for. If you dont mind can you share the codes you used and any lessons learnt along the way?
Thank you
Garfield
- 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