Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 676 through 690 (of 2,989 total)
  • Author
    Search Results
  • #48691

    Topic: Day of Year

    Glen Forister
    Participant

    DateCollected

    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.

    Attachments:
    You must be logged in to view attached files.
    #48682

    In reply to: Learning JavaScript

    Daniel Leu
    Participant

    Hmmm… 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&tricks

    #48680

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    Sorry. 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.
    #48678

    In reply to: List with Check box

    Glen Forister
    Participant

    Unfortunately, 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.

    #48675

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    That 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 1

    if (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();

    #48674

    In reply to: Learning JavaScript

    Daniel Leu
    Participant

    The 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&tricks

    #48671

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    Thanks 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?

    #48668

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    I 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?

    #48666

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    I 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?

    #48657

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    That 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.310

    Brandon’s script results
    0.03 0
    0.31 0.310
    0.23 0.230.310
    0.33 0.330.230.310

    #48655

    In reply to: Learning JavaScript

    Daniel Leu
    Participant

    Sorry, 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&tricks

    #48654

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    That loop script doesn’t do anything either.

    #48652

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    I’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 total

    I 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?

    #48651

    In reply to: Learning JavaScript

    Glen Forister
    Participant

    I’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 total

    I 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?

    #48650

    In reply to: Learning JavaScript

    Brendan
    Keymaster

    Thanks 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?

Viewing 15 results - 676 through 690 (of 2,989 total)