Vitalikssssss Posted October 29, 2018 Report Share Posted October 29, 2018 Hi there guys, How can I change the status of the event (open/close) based on the expiration date in Gallery report datapage? Thank you for looking into this question. Quote Link to comment Share on other sites More sharing options...
Andrii Posted October 29, 2018 Report Share Posted October 29, 2018 Hello. You can implement such a workflow using JavaScript. First of all, you need to add one HTML block to define the statuses. Here is the example of the HTML block: 1. Open Status. You can also insert the link of your registration form in the "href" property. 2. Closed Status. 3. Field to copy the date of the expiration. Use the parameter picker to insert the date value. Use the "Short date" format. Then you need to add header/footer and insert this snippet of code in the footer: <script type="text/javascript"> var elemOpen = document.getElementsByClassName('Open'); var elemClose = document.getElementsByClassName('Close'); var elemDate = document.getElementsByClassName('Date'); document.addEventListener('DataPageReady', function () { for(var i = 0; i < elemDate.length; i++) { var dateArr = elemDate[i].innerHTML.split("/"); var date = new Date(dateArr[2] + "-" + dateArr[1] + "-" + dateArr[0]).getTime(); var milSecDay = 86400000; var currentDate = Date.now(); var differDay = (date - currentDate) / milSecDay; if(differDay > 4) { elemOpen[i].style.display = ""; } if(differDay < 4) { elemClose[i].style.display = ""; } } }); </script> If you want, you can import my application and play around with the datapage to get familiar with this idea. Find the application attached. JS_Change_Status_based_on_Date.zip 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.