change the state and active in contract on condition

mregragui_ext
Tera Contributor

hello,

i want to change the state to expire and active to false in conctracts table whenever a contract END and renewel end is in the past.

Thanks for help!

5 REPLIES 5

Anand Kumar P
Giga Patron
Giga Patron

Hi @mregragui_ext ,

You can write before update business rule on contract table and use below script or in business rule filter condition Contract end before today and Renewal end before today and update active and state field.

 

(function executeRule(current, previous /*null when async*/) {
var ctrend=new GlideDateTime(current.contract_end_date_backendname.getDisplayValue());
var renwlend=new GlideDateTime(current.renewal_end_date_backendname.getDisplayValue());
    var nowDate = gs.now();
    if (ctrend < nowDate && renwlend < nowDate) {
        current.state = 'expire';
        current.active = false;
    }
})(current, previous);

 

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

 

@Anand Kumar P    NOT working the state and active don't change and i want it to change without entering the record please.

Thanks!

Hi @mregragui_ext ,

Write before update business rule When to run filter condition Contract end Date before today and Contract renewal before today

Use below script

 

(function executeRule(current, previous /*null when async*/) {

current.state='expirebackedname';
current.active='false';
current.setWorkflow(false);
current.update();
    }
})(current, previous);

 

While testing update both Contract end date and Renewal date before today and check the state and active updated or not.

I have tried for incident table in my pdi its working

AnandKumarP_0-1701171333009.png

 

AnandKumarP_1-1701171355856.png

 

AnandKumarP_2-1701171372069.png

 

Thanks,

Anand

 

br 1.pngbr 2.png

Not working when i reload the list nothing changed

@Anand Kumar P