Decrement of timer field in a customized table

Madhan27
Mega Guru

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

 

------------------------------------------------------------------------

 

Madhan27_0-1694636300527.png

 

(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_test_fault][u_fault_imer] !== null && current[u_test_fault][u_fault_imer] >= decrementValue) {
        current[u_test_fault][u_fault_imer] -= decrementValue;
    } else {
        // If the timer field is less than the decrement value or null, set it to 0
        current[u_test_fault][u_fault_imer] = 0;
    }

})(current, previous);

 

#Event management

2 REPLIES 2

Bert_c1
Kilo Patron

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.

 

HI @Bert_c1 ,

 

Thank you for your quick response, But even the same its incrementing.

 

Madhan27_0-1694651893497.png

 

 

Madhan27_1-1694651938982.png

 

I have pasted the same script, But there's no luck on it