This site has been archived. Please visit help.fulcrumapp.com for our new support documentation and contact information.

Data Event triggered by comparing date field to current date

Kevin Crespo's Avatar

Kevin Crespo

14 Nov, 2016 07:31 PM

Is there a way to set a data event based on a date field so a message is triggered when the date field record data (in this case the field is related to an expiration date) reaches the current date?
I'm building a transportation data and would like for the app to notify when either the vehicle registration or the drivers license expires.

  1. Support Staff 1 Posted by Alex Helms on 14 Nov, 2016 09:06 PM

    Alex Helms's Avatar

    Hello Kevin,

    I got this to work:

    ON('load-record', function(event) {
      if($expiration_date >= $todays_date) {
        ALERT('The date is expired');
      }
    });
    
    ON('save-record', function(event) {
      SETVALUE('todays_date', null);
    });
    

    You will need to add a date field with a data name of 'todays_date' and set it to default with today's date. To first data event will go through and see if 'expiration_date' is greater than or equal to the todays_date field. If so the ALERT() will be displayed. When the record is saved, the todays_date field will be cleared out and then it will auto populate with today's date the next time the record is edited.

  2. 2 Posted by Kevin Crespo on 16 Nov, 2016 12:31 PM

    Kevin Crespo's Avatar

    Have not tested it yet, but it looks to me that this will work only while you are editing a record. Is there a way to make the comparison against the current date without the need of having a record for todays_date? Id like the alert to come on whenever the record is opened for viewing, not editing. It will be obvious for the person entering the data if the license is expired but expiration dates will not be tracked on a daily basis, so the purpose of the data event would be to notify of the situation if you open (load) a record at a later date and not necessarily editing the record.

  3. Support Staff 3 Posted by Alex Helms on 16 Nov, 2016 02:36 PM

    Alex Helms's Avatar

    There is no way to trigger a notification or alert when the record is just being viewed. Only the record editors have the functionality to run code in a data event or calculation field.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac