change the state and active in contract on condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 02:10 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 02:28 AM - edited ‎11-28-2023 02:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 03:08 AM
@Anand Kumar P NOT working the state and active don't change and i want it to change without entering the record please.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 03:19 AM - edited ‎11-28-2023 03:36 AM
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
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 04:48 AM - edited ‎11-28-2023 04:51 AM