Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
January 18, 2023 at 5:02 PM #48691
Topic: Day of Year
in forum Using Tap Forms 5Glen Forister
ParticipantDateCollected
I’m interested in obtaining the day of the year (1 to 365).
To do that I see how to insert another date field from the “Edit Formula” screen.
The “Date Collected” in the pic attached.The problem is I don’t know how to get the difference (IN DAYS):
– from Date which might be any of the last few years or future year
and
– Jan 1 of that year (or any year – not worried about leap year).My attached pic shows in that col (Day of Yr) the calculated days in text, but that got there from exporting out of another database program where it was calculated. But, future additions need to be calculated.
Any help? I hope it isn’t a program script. So far I haven’t had any luck with that solution on another Form.
Thanks.
-
This topic was modified 3 years ago by
Glen Forister.
-
This topic was modified 3 years ago by
Glen Forister.
Attachments:
You must be logged in to view attached files.January 16, 2023 at 9:08 PM #48682In reply to: Learning JavaScript
Daniel Leu
ParticipantHmmm… your dataset doesn’t have an October 1st in there. So it doesn’t show that it works. At lest to me it seems to be working.
If it still doesn’t work for you, did you do a “Refresh Record List”? Otherwise, please explain what’s not working.
BTW, this is a field script as mentioned in https://www.tapforms.com/forums/topic/learning-javascript-2/#post-48648
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJanuary 16, 2023 at 5:31 PM #48680In reply to: Learning JavaScript
Glen Forister
ParticipantSorry. That isn’t doing it. Look at my file and see what isn’t working.
I tried putting it in the “Scripts” tab, and in the Field/Season Total tab in Scripts.
Thanks for trying again.
Attachments:
You must be logged in to view attached files.January 16, 2023 at 3:41 PM #48678In reply to: List with Check box
Glen Forister
ParticipantUnfortunately, I have a form with checkmarks for 3 categories of items and a description of the item. In my old database I could check filter for a category if I wanted to (grouping them). Then the 1st checkbox was for when I had secured the item when I would check the item off the list.
In Tap Forms I put the first checkbox on the top (iphone on left of table view).When I do this, I can’t check any of the items unless I go into that record.
That is very distracting while searching for items to obtain and a waste of time.Also, about checkboxes there is something you really need that I can’t find. When I am finished with my operation of finding the things in the list (those all have the “get FIELD” checkbox checked which can be a lot of checks. When I remove the filter to bring all those items back from that FIELD onto the viewable form they are all visible. You need (if you don’t have) a way to select a FIELD of checkboxes and remove all the checks, or add all the checks depending.
In fact, it would be useful for many FIELD types (text, checkbox, number) to be able to replace all the items in that FIELD to something else.
January 16, 2023 at 2:25 PM #48675In reply to: Learning JavaScript
Glen Forister
ParticipantThat is great. I put it in the script right after the other “var”s near the top. Hope that is the right place.
function Get_Previous_Record() {
var records = form.getRecords();
var currentRecordIndex = records.indexOf(record);
// added var for Oct 1st.
var previousRecord = nil;
var date = record.getFieldValue(‘fld-0720a5baa6fc4980aee22798bd089714’);
if (date.getMonth() == 9 && date.getDate() == 1){ // check for October 1st
return 0;
}
// end added var for Oct 1if (currentRecordIndex > 0) {
previousRecord = records[currentRecordIndex – 1];
}if (previousRecords != nil) {
// fetch some value and do some calculation with it and the current record
// the currently selected record is always accessed with the built-in variable
//record
}
}Get_Previous_Record();
January 16, 2023 at 1:13 PM #48674In reply to: Learning JavaScript
Daniel Leu
ParticipantThe script checks for January 1st and if there is match, the return value is set to 0.
Here is the update for checking for October 1st:
var date = record.getFieldValue('fld-0720a5baa6fc4980aee22798bd089714'); if (date.getMonth() == 9 && date.getDate() == 1){ // check for October 1st return 0; }Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJanuary 16, 2023 at 10:13 AM #48671In reply to: Learning JavaScript
Glen Forister
ParticipantThanks for the script. Wish I could understand it, but…
Actually, the beginning of each rainy season is Oct 1 of the previous year extending to Oct 1 of this year.
The records in my current view is only those records in that range, but sometimes I look at previous years with a different view search pattern.
Will this do the job with that parameter?
January 15, 2023 at 3:29 PM #48668In reply to: Learning JavaScript
Glen Forister
ParticipantI missed that import setting.
Thanks.
I imported all 5 years of data and now when I create a filter and just view this season, which is 38 records, the script sees all the records, not just this season.Do I need to create another field to delete the total at the beginning of the season to find the total for the season, or is there a more elegant way?
January 15, 2023 at 2:23 PM #48666In reply to: Learning JavaScript
Glen Forister
ParticipantI figured that out. thanks.
The file I used was for learning and had only this season. I thought it would be good to start with a small file.
I tried to import the whole 5 years into the file, but import created a new file Form with the same name instead of adding to the current form. So I tried to duplicate the format for the new form but failed. I think I have all the file properties correct, but the script just gives me “NaN” in the field (even after repeated refresh). You have a clue what I missed, or can I copy records from this form and add them to the working form?BTW, somehow the Date col disappeared which produced bogus charts obviously. I added a new Field (DATE) and moved it to the top and after configuring the field the original data appeared out of nowhere. What happened here? I couldn’t find that data until it suddenly appeared, and how did it disappear in the first place?
January 14, 2023 at 7:23 PM #48657In reply to: Learning JavaScript
Glen Forister
ParticipantThat didn’t quite work. Looping to get all every time? Here is the first 3 lines of the relult. This is one thing I like about programming, always a surprise.
Day tot. Sum
0.03 0
0.31 0.310
0.23 0.230.310
0.33 0.330.230.310Brandon’s script results
0.03 0
0.31 0.310
0.23 0.230.310
0.33 0.330.230.310-
This reply was modified 3 years ago by
Glen Forister.
January 14, 2023 at 4:14 PM #48655In reply to: Learning JavaScript
Daniel Leu
ParticipantSorry, this is intended to be a field script for the Season Tot field.
And you need to run Refresh Records List (control-option R).
-
This reply was modified 3 years ago by
Daniel Leu.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksJanuary 14, 2023 at 3:47 PM #48654In reply to: Learning JavaScript
Glen Forister
ParticipantThat loop script doesn’t do anything either.
January 14, 2023 at 3:41 PM #48652In reply to: Learning JavaScript
Glen Forister
ParticipantI’m recording daily rain fall (morning, noon and night)I want each record to show the total for that day (done) and add that to the previous season total to get the new season total.
each record has the total for the day and the season totalI added the Script to the list of Scripts, then noticed the change of field properties to Script instead of Calculated and put the script there, but nothing happened.
Am I supposed to change the script to enter the field somewhere?
Why a loop?
-
This reply was modified 3 years ago by
Glen Forister.
January 14, 2023 at 3:41 PM #48651In reply to: Learning JavaScript
Glen Forister
ParticipantI’m recording daily rain fall (morning, noon and night)I want each record to show the total for that day (done) and add that to the previous season total to get the new season total.
each record has the total for the day and the season totalI added the Script to the list of Scripts, then noticed the change of field properties to Script instead of Calculated and put the script there, but nothing happened.
Am I supposed to change the script to enter the field somewhere?
January 14, 2023 at 3:09 PM #48650In reply to: Learning JavaScript
Brendan
KeymasterThanks for posting your script Daniel. I had a couple syntax errors in mine which I updated to fix.
I wonder if Glen wants a cumulative total and not just a total from the previous and today’s totals? If that’s the case, then maybe a Form level script to loop through all the records and update a cumulative total field would be required?
-
This topic was modified 3 years ago by
-
AuthorSearch Results