Why the reson is not working in workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 05:53 AM - edited ‎03-26-2024 05:54 AM
Hi,
We have wrote BR and client script for when the before time worked field is updated it should show error message on problem form. Its working fine in problem form but when i checking the workspace it is not working.
Can you please help on this Why the reason is not working on SOW. It will be helpful.
BR: display
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
g_scratchpad.time_worked_prb = current.time_worked.dateNumericValue();
g_scratchpad.prb_assmntGroup = current.assignment_group;
g_scratchpad.prb_assigned_to = current.assigned_to;
//gs.info("Time component of the timer field in milliseconds: " + milliseconds);
gs.info("From Problem Display Rule1 " + current.time_worked);
gs.info("From Peoblem Display Rule2 " + current.time_worked.dateNumericValue());
})(current, previous);
Client Script:
function onSubmit() {
///get the value of time worked as the user tries to update/save thee form
//alert("Onsubmit started");
var asgnGroup = g_form.getValue('assignment_group');
var assignTo = g_form.getValue('assigned_to');
if (!g_form.isNewRecord() && asgnGroup == g_scratchpad.prb_assmntGroup && assignTo == g_scratchpad.prb_assigned_to) {
var timer = g_form.getValue('time_worked');
//multiply time worked integer value by 1000
var dateNumeric = timer * 1000;
var hours = timer.split(':')[0];
var minutes = timer.split(':')[1];
var seconds = timer.split(':')[2];
// Convert time components to milliseconds
var milliseconds = ((hours * 60 * 60) + (minutes * 60) + seconds) * 10;
//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
// alert("time worked " + g_form.getIntValue('time_worked'));
//alert("time worked ms " + milliseconds);
//alert("time worked scratchpad " + g_scratchpad.time_worked_chg);
var action = g_form.getActionName();
//alert("Onsubmit line 22 " + action);
//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' || action == 'move_to_rca' || action == 'move_to_fix_in_progress' || action == 'move_to_resolved' || action == 'accept_risk' || action == 'sysverb_modal_ok' || action == 're_analyze' || action == 'mark_duplicate') {
var diff = milliseconds - g_scratchpad.time_worked_prb;
if (diff == 0) {
alert('Please enter Time Worked before updating Record. Thank You.');
return false;
}
}
}
}
Thanks in Advance!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 06:02 AM
Hi @mania ,
you can specify the view for your client script as -> workspace
then write your code which would run only for the workspace view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 06:16 AM
@Community Alums
Thanks for your Responding!
I have tried which you provided lines but not working on workspace view.
Can you please suggest me and help me.
Thanks!
Mania
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2024 07:49 AM
@Community Alums
I have set that ui type field is All and Isolated script check box is true on client script then also not working.
Can you please help with that query. It will be useful.
Thanks!
Mania