pilotexpressions Posted March 15, 2016 Report Share Posted March 15, 2016 <script> var today =new Date(); var signup = new Date( "[@authfield:Serial_Numbers_Last_Payment]" ); var renew = new Date( "[@authfield:Sheet1_Last_Payment]" ); var valid = new Date(); valid.setDate(today.getDate()-365); if (valid<signup) { /*Valid*/ document.location = "http://valid-sample.com"; } else if (valid<renew) { /*Valid*/ document.location = "http://valid-sample.com"; } else { /*Not Valid*/ window.location = "http://invalid-sample.com" } </script> Hi all, I'm using this script to validate a customers annual subscription status by date. It works well, except a customer may have multiple dates (in my app, when a customer buys a standalone subscription or buys a new product w/subscription this makes a timestamp in my datatable), but my script is only interrogating the first date it finds and either validates it or invalidates it. Lets say a customer bought a product 3/10/2015 and then buys another product on 3/11/2016, I want the script to look at the two dates and validate the latest date (3/11/16). Currently the script only seems like it is looking at the first date (3/10/15) and invalidating the subscription because it is over 365 days old. How may I change the script to allow it to keep searching for a valid date, if there is one? Thanks for the help! Logan Quote Link to comment Share on other sites More sharing options...
LWSChad Posted March 18, 2016 Report Share Posted March 18, 2016 sort your data differently? Quote Link to comment Share on other sites More sharing options...
pilotexpressions Posted March 19, 2016 Author Report Share Posted March 19, 2016 Hi Chad, I've tried sorting my tables based on date, however, it still returns as non-valid if there is a date that is +365 days even though there may be a date that is -365 days. Logan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.