Cameron Posted June 3, 2015 Report Share Posted June 3, 2015 Hello everyone! I try to filter records by "previous month", but I cannot find the filter. There are the "Current Month", "Before Now", "Previous X Days" filters. I tried them all one by one and I tried combining of these filters, but the problem is "Previous X Days" is variable. I mean, today the previous month is: IS Previous 34 days AND NOT Current Month But tomorrow it should be 35 days... Any ideas are very much appreciated! Thank you for your time! Quote Link to comment Share on other sites More sharing options...
iren Posted June 3, 2015 Report Share Posted June 3, 2015 Hello Cameron, You can insert new criteria in your Report DataPage to filter the field by two boundaries. For a Date field you can have two Criteria, FROM and TO so you can search for records that fall within a specific date range. Hope it helps. Quote Link to comment Share on other sites More sharing options...
Cameron Posted June 3, 2015 Author Report Share Posted June 3, 2015 Thank you for your answer! I apologize, if I was unclear. I want to filter by previous month automatically, so user should not to enter any dates. If it's possible, of course. Quote Link to comment Share on other sites More sharing options...
iren Posted June 3, 2015 Report Share Posted June 3, 2015 You can use the 'Filter data based on pre-defined criteria' option, to insert new criteria and enter conditions for range. Does it work for you? Quote Link to comment Share on other sites More sharing options...
Cameron Posted June 3, 2015 Author Report Share Posted June 3, 2015 Thank you for your time! But I do not understand, which the pre-defined criteria can I use to filter records automatically? Is it something like the "Timestamp" System parameter? Quote Link to comment Share on other sites More sharing options...
Jan Posted June 3, 2015 Report Share Posted June 3, 2015 Hello Cameron, If I understand correctly, you can use a JavaScript code. If you want to filter only by the "previous month" filter: 1) On the "Search Type" step, select "Allow users to select data using a search form"; 2) On the "Select Search Fields" step, add your field with date; 3) On the "Configure Search Fields" step, - select your field with date, select the "Month and Year" in the "Precision" dropdown; - add Header&Footer element, select "Footer", click the "Source" button and enter the following code: <SCRIPT LANGUAGE="JavaScript"> if(document.getElementById("caspioform")) { document.getElementById("caspioform").style.display = 'none'; var nDate = new Date(); var baseMonth = nDate.getMonth(); var nPreviousMonth = baseMonth - 1; var dPreviousMonth = new Date (nDate.setMonth(nPreviousMonth)); var searchMonth = dPreviousMonth.getMonth() + 1; if (searchMonth<10) {searchMonth = "0" + searchMonth; } var searchYear = dPreviousMonth.getFullYear(); var searchString = searchMonth + "/" + searchYear; document.getElementById("Value1_1").value=searchString; setTimeout('document.forms["caspioform"].submit()',1000); } </SCRIPT> The code enters previous month in the Search field and clicks "Search" button. User does not see the Search page, he or she sees Results page. If you want to filter by other fields, 1) On the "Search Type" step, select "Allow users to select data using a search form"; 2) On the "Select Search Fields" step, add fields; 3) On the "Configure Search Fields" step, - select your field with date, move it up to the first position, select "Hidden" in the "Form element" dropdown, select the "Month and Year" in the "Precision" dropdown; - add Header&Footer element, select "Footer", click the "Source" button and enter the following code: <SCRIPT LANGUAGE="JavaScript"> if(document.getElementById("caspioform")) { var nDate = new Date(); var baseMonth = nDate.getMonth(); var nPreviousMonth = baseMonth - 1; var dPreviousMonth = new Date (nDate.setMonth(nPreviousMonth)); var searchMonth = dPreviousMonth.getMonth() + 1; if (searchMonth<10) {searchMonth = "0" + searchMonth; } var searchYear = dPreviousMonth.getFullYear(); var searchString = searchMonth + "/" + searchYear; document.getElementById("Value1_1").value=searchString; } </SCRIPT> The code enters previous month as one of search criteria. Does it work for you? Quote Link to comment Share on other sites More sharing options...
Cameron Posted June 4, 2015 Author Report Share Posted June 4, 2015 Hi Jan, Yes, it works! Thank you for your time! Quote Link to comment Share on other sites More sharing options...
scribblemilk Posted August 3, 2016 Report Share Posted August 3, 2016 Hi Jan, Is it possible to use javascript to filter on the last record entered (potentially via a timestamp), using the same principle of using a search page you have above? I have users submitting multiple records and I need to be able to automatically select the last record submitted to edit, is this possible? Regards Jason Quote Link to comment Share on other sites More sharing options...
alexm72 Posted August 26, 2016 Report Share Posted August 26, 2016 How do i filter records that are stamped for the last hour, minute? There's filtering for today, month, etc but no filter for records entered in the last hour unless I'm missing something?? Quote Link to comment Share on other sites More sharing options...
anusers13 Posted August 29, 2016 Report Share Posted August 29, 2016 it is also possible to filter by using this javascript Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted July 16, 2021 Report Share Posted July 16, 2021 On 8/3/2016 at 2:35 PM, scribblemilk said: Hi Jan, Is it possible to use javascript to filter on the last record entered (potentially via a timestamp), using the same principle of using a search page you have above? I have users submitting multiple records and I need to be able to automatically select the last record submitted to edit, is this possible? Regards Jason Hi @scribblemilk, you might want to try this workaround that I discover. First, create a Tabular DataPage and choose your data source. Filter the report using your Date field and set the comparison type to 'Before Now'. Then, choose the fields for your Results page and paste this script to your Footer. This script will automatically redirect you to details page where you can edit the last submitted record. <script> var bulkEditSubmit = document.querySelector('.cbResultSetActionsLinks[data-cb-name=DetailsLink]'); console.log(bulkEditSubmit); setTimeout( () => { bulkEditSubmit.click(); }); </script> Choose your Date field and sort it in descending order. Set the records per page into 1 only. Lastly, enable the Details page and configure the fields you want to be editable. Also, you have the option to disable the navigation to the next or previous records. Here is a sample DataPage I made: https://c0hcv332.caspio.com/dp/3b43900055adaba2de354b22ad43 I hope this helps! eunha 1 Quote Link to comment Share on other sites More sharing options...
GoodBoy Posted September 7, 2021 Report Share Posted September 7, 2021 On 7/16/2021 at 3:13 PM, GoodBoy said: Hi @scribblemilk, you might want to try this workaround that I discover. First, create a Tabular DataPage and choose your data source. Filter the report using your Date field and set the comparison type to 'Before Now'. Then, choose the fields for your Results page and paste this script to your Footer. This script will automatically redirect you to details page where you can edit the last submitted record. <script> var bulkEditSubmit = document.querySelector('.cbResultSetActionsLinks[data-cb-name=DetailsLink]'); console.log(bulkEditSubmit); setTimeout( () => { bulkEditSubmit.click(); }); </script> Choose your Date field and sort it in descending order. Set the records per page into 1 only. Lastly, enable the Details page and configure the fields you want to be editable. Also, you have the option to disable the navigation to the next or previous records. Here is a sample DataPage I made: https://c0hcv332.caspio.com/dp/3b43900055adaba2de354b22ad43 I hope this helps! Hello! I just want to update this workaround since I have found a way that will show the last submitted record without using any JavaScript. First, delete the existing script I have mentioned in the previous reply. Then, go to the Advanced tab of the Results Page Options window and set the Total Records returned into 1. Then, go to the next window and check this checkbox so that it will automatically skip the results page, and show the details page immediately for the last submitted record. Lastly, save the DataPage. Hope this helps! eunha 1 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.