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 - 871 through 885 (of 2,989 total)
  • Author
    Search Results
  • #47407
    Brent Willingham
    Participant

    Ok, I’ve created a new database called Wildlife Exemption and a form called Wildlife. I’ve created all my fields, one of which is a Pick List field called “Management Practice”. I created a corresponding pick list also named “Management Practice”. There are 7 values in the “Management Practice” pick list. One of the values is “Habitat Control”.

    I have created pick lists for each of those 7 values that I am referring to as “sub practices”. So, for example, I have a pick list called “Habitat Sub Practice”. In that pick list are things like Grazing Management and Brush Management.

    The idea is that when the user is on the “Management Practice” field, they are presented with the list from the “Management Practice” pick list. They have 7 options, but let’s say the choose “Habitat Control”. The next field on the form is called “Sub Practice”. In this field, the pick list “Habitat Sub Practice” would be chosen because of the selection above.

    The only way I can think of to do this is with a long nested IF THEN kind of routine:
    IF Management Practice = “Habitat Control” THEN “Habitat Sub Practice”
    ElSE IF Management Practice “Erosion Control” THEN “Erosion Sub Practice”
    and do 5 more ELSE IF’s so that all 7 Management Practice options are covered.

    I’m guessing that this is probably not the smartest way to go about it, and I’m sure I have the syntax way off. I’ve gone through T.L. Ford’s Java Scripting 101 and that has been very helpful, but my only programming experience is with BASIC decades ago in High School.

    Would someone be able to get me kicked off with the start of a script here?

    Thanks,
    Brent

    #47404

    In reply to: Tap Forms Form Hooks

    Bernie McGuire
    Participant

    Brendan Hi Ok Ill think about this. I guess there is no problem to insert a Record in a different form than the form with the field script, correct ? Ill give it a try and post here the results.
    Bernie

    #47403

    In reply to: Tap Forms Form Hooks

    Brendan
    Keymaster

    Field scripts execute whenever a value they’re monitoring changes. So if you’re entering data anyway, you could monitor for that change and insert the records you want at that point. You don’t even have to be doing anything with the field you’re monitoring. Just to know that it has changed and the script will be triggered. But no script will get triggered just by viewing a record.

    #47401

    In reply to: Tap Forms Form Hooks

    Bernie McGuire
    Participant

    Brendan Hi thanks for the opportunity to explain. I will try to be brief but somewhat detailed.
    I have 3 linked forms
    1. Drill Description
    2. Drill Results (One record for each time a drill is executed)
    3. Drill Total Results (One Record for each Drill with accumilated totals of rows in number 2 above. Totals are calculated using Calculation of linked fields

    One time process : Load a description for all possible drills in Form 1 assign a ‘DrillID”

    Eacb time a drill is executed :
    1. Open form 1, drill description
    2. Pick a drill and click on the + next to linked Form Drill Results (2)
    3. Enter Results and either pick a new Drill Description or exit

    The Problem as I see it. The records in table 3 (Drill Total Results) need to be manually added the first time a drill has results which for me, is extra work on the user part I like to avoid. As if the user forgets to pen the Form and add a row, no totals will ever be displayed.

    What I have done is write a script that will look at all the records in table 2 (Results) and check if a Record exists (by Drill ID) in Table 3 (Totals), if exists, do nothing, if not exists add new row. Now when a Drill Description is open the linked forms for both Results and Totals will be present and viewable.
    This script has to be executed manually using the Form Run Script command. It would be nice if it could be executed ‘ON Open’ automatically.
    Or is there another way to accomplish script execution without user intervention?

    Hope this is clear.
    Thanks for the help
    Bernie

    Michael Tucker
    Participant

    These MOASS Ladder templates have gotten some revisions..

    (1) Mainly I had forgotten to connect the fractional shares field, and when corrected that blew three scripts, all revised.

    (2) Then also I have added a way to re-use the Goal Section within multiple Ladders. Usually your goal list would remain static.

    New versions below.

    #47391
    Bernie McGuire
    Participant

    Are there any available hooks in a Form such as ‘ON Open” o ‘On Close’ etc. Where one could have a script execute based on this event?
    Thanks

    #47371
    Brendan
    Keymaster

    Hi David,

    You can do this with a Calculation field, but it would be much easier to understand with a Script field.

    Just off the top of my head without actually testing it out, here’s a script that “should” work:

    function getResult() {
       let margin_id = 'fld-....';
       let money_id = 'fld-....';
       let margin = record.getFieldValue(margin_id);
       let money = record.getFieldValue(money_id);
       var result = 0;
    
       if (margin < 25)
          result = 0;
       } else if (margin >= 25 || margin <= 27) {
          result = money * 0.08;
       } else if (margin > 27 || margin <= 30) {
          result = money * 0.1;
       } else {
          // not sure what happens if margin is greater than 30?
       } 
     
       return result;
    
    }
    
    getResult();

    So add a Field Script and copy this code into your script and then change the field IDs appropriately to match the actual field IDs of your own Margin and Money fields.

    It should work.

    Thanks,

    Brendan

    #47370
    David Figge
    Participant

    Ok, I am trying to learn some scripting for the calc field but I am running out of time in my evaluation process of TF (which so far has been amazing) and we have a use case that we can do in Numbers but unsure if we can in TF.

    I am trying to do an if/then usineg two fields. One is a Margin field (which is a number field) and the other is a money field. Basically I am trying to get a final calculation from certain numbers. It looks like this

    I the (Margin) is <25 then 0
    If the (Margin) is > or equal to 25-27 then (Money) * .08
    If the (Margin) is > or equal to 27-30 then (Money) * .10

    Is this possible in the calculation field and if so…If someone would be willing to show me how it will help a ton with me starting to understand exactly how this scripting works.

    #47326

    In reply to: Help with a script 3

    Brendan
    Keymaster

    Oh, it’s just a matter of the wrong field IDs in the script. I guess I used an archive of the form you sent me a while ago to write the script. You also renamed the Kalvningar field to Antal kalvningar so that took me a minute to find it again.

    var kalvningar_id = 'fld-cdb4431a905f4b1dbaa750b07a63b6f1';

    When you see an error in the console, first check to make sure all the field IDs in the code match the field IDs on the left. You can select a field and see its ID below.

    #47317

    In reply to: Help with a script 3

    Daniel Leu
    Participant

    Hi Stig, instead of sharing a TapForms template, could you share a TapForms archive of a document that contains entries for just a few animals? I tried to see what the script does, but it returns an error. I don’t know if I missed to enter some data or if there is an issue with the script. Having a TapForms archive with known data would make debugging much easier. Thanks!

    Cheers

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #47315

    In reply to: Help with a script 3

    Stig Widell
    Participant

    Thank you Brendan for your efforts.
    Unfortunately I have to bother you once more because nothing shows up in the added script fields.
    Regards
    Stig

    Attachments:
    You must be logged in to view attached files.
    #47310
    Brendan
    Keymaster

    Hi Victor,

    It looks like I never really flushed that one out. It’s just returning exactly what you see. The search object with it’s ID and name.

    The primary use of AppleScript in Tap Forms would be to run a script within Tap Forms. And from there you can reference a search and get its records and perform some operation on the results.

    Thanks,

    Brendan

    #47309
    Brendan
    Keymaster

    Hi Sebastian,

    1. Custom layouts are fixed according to the x, y, height, and width settings you provide for it. There’s no workaround to make them dynamically sizeable. Sorry.

    2. The only way to show data from a Link to Form field in a Table or other Link to Form field’s table view is to add a Field Script which loops through all of the child records from the relationship and appends them into a big string to display. But even then there won’t be a whole lot of room because you can’t adjust the height of a row, only the width of the column. The Script Editor has a built-in snippet called Child Records Loop which is a starting point for building that kind of a function.

    Thanks,

    Brendan

    #47300
    Daniel Leu
    Participant

    It looks like @Sam has been busy lately. You might browse his GitHub repository where he has amassed different tools and scripts supporting TapForms: https://github.com/pasamio/tftools

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #47296
    Victor Warner
    Participant

    In the Applescript Tap Forms dictionary there is the following:

    search n, pl searches : A search item
    elements
    contained by forms.
    properties
    id (text, r/o) : The unique identifier of the search.
    name (text) : The name of the search.

    Is this for running a saved search, so that the result is that Tap Forms shows the records which match the criteria for the saved search?

    Also what is the syntax for this AppleScript item?

    Any help would be gratefully received.

Viewing 15 results - 871 through 885 (of 2,989 total)