Decrement of timer field in a customized table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 01:19 PM
Hi community,
I am trying to decrement time in a timer field (Data type is timer), We don't have any OOB functionality in order to decrement. So I am trying to achieve this with business rules and wrote advanced scripts, Even though couldn't achieve the solution. Attached screen shots for the ref.
Can some one please correct me or suggest me if any changes in the below following script.
TIA
------------------------------------------------------------------------
#Event management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 03:01 PM - edited 09-13-2023 03:01 PM
Hi Madhan27,
if your BR is defined on the 'u_test_fault' table then use the following syntax:
(function executeRule(current, previous /*null when async*/) {
//(function executeRule(current, previous /*, g */) {
// Define the decrement value in milliseconds (1 minute = 60000 milliseconds)
var decrementValue = 60000; // 1 minute
// Replace 'your_table_name' with the actual table name
var tableName = 'u_test_fault';
// Replace 'your_timer_field' with the actual timer field name
var timerFieldName = 'u_fault_imer';
// Check if the timer field is not null and greater than or equal to the decrement value
if (current.u_fault_imer !== null && current.u_fault_imer >= decrementValue) {
current.u_fault_imer -= decrementValue;
} else {
// If the timer field is less than the decrement value or null, set it to 0
current.u_fault_imer = 0;
}
})(current, previous);
no need to use array notation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2023 05:39 PM
HI @Bert_c1 ,
Thank you for your quick response, But even the same its incrementing.
I have pasted the same script, But there's no luck on it