Checking or unchecking Active check box, should update the active or inactive date fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 11:55 AM
Hi,
I have created Active field as true/false to check/uncheck and created active date and inactive date fields as date/time. Now when the active box is true, active date should be updated with date when the active box was made true. When 'active' is false, inactivate date should be updated with the date when the active box was made false. How to achieve this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 01:25 PM
Try the updated code below and make sure column names are correct.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
//Type appropriate comment here, and begin script below
if(current.active == true){
current.active_date = new GlideDateTime().getDisplayValue();
}
else{
current.inactive_date = new GlideDateTime().getDisplayValue();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 12:02 PM
Create a before business rule
when: before insert and update
conditions: Active changes
Script:
if(current.active){
current.<field_name of active date> =gs.nowDateTime();
//current.<field_name of inactive date>='' ;//take out the comments if you need to clear the inactive date
}
else{
current.<field_name of inactive date>=gs.nowDateTime();
//current.<field_name of active date>='' ;//take out the comments if you need to clear the active date
}