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 - 2,536 through 2,550 (of 2,864 total)
  • Author
    Search Results
  • #33088
    Brendan
    Keymaster

    You’ll have to use a Script Field for this because the Calculation field cannot reference specific sub-records of a Link to Form field.

    var passport_field_id = 'fld-....';
    var passportRecords = record.getFieldValue(passport_field_id);
    if (passportRecords.length > 0) {
       var firstPassportRecord = passportRecords[0];
       var number_field_id = 'fld....';
       var number = firstPassportRecord.getFieldValue(number_field_id);
    
       // and do whatever you want with the values/
    
    }

    Hope that makes sense.

    But what you could do maybe instead of trying to extract the passport information on the Client Contact form into a Calculation field, you could go the other way around and if you’re using a One-to-Many Link Type from Client Contact to Passports, then you could add a Calculation field to your Passports form that references the Client Contact data. In that situation because it’s as One-to-Many relationship, the inverse of that is a Many-to-One and you can reference individual fields from the one Client Contact record from within the Passport records. You’ll notice that if you double-click on the inverse field of a One-to-Many relationship in the Formula Editor, you’ll get something like Client Contact::First Name instead of one of the aggregate math functions.

    Thanks,

    Brendan

    #33074
    Brendan
    Keymaster

    Hi Ian,

    On a custom layout you can add a button which you can click on to trigger a Form Script.

    Click the custom layout, then the Layout button. At the top-right of the Layout Inspector panel you’ll see a “button” button. Click on it, then drag out a rectangle on your custom layout. Now on the Layout inspector panel you can set the Form Script to trigger when you click the button.

    Hope that helps!

    Brendan

    #33071
    Ron
    Participant

    Check out the Scripts page of the v5.3 manual. It gives a sample of the Prompter() function which seems to be what you are looking for.

    Ron

    Ian Heath
    Participant

    Is there a way to use the share/send-to option on iOS Safari to pass information to Tap Forms? What I’m thinking is some sort of bookmark manager functionality so I’d want to pass the URL and title into a predetermined database. Alternatively would this be possible via a Safari bookmark with some Javascript in it, like I’ve seen for other bookmarklet functionality in the past?

    #33068
    Ian Heath
    Participant

    I’m making a cataloguing database for things like DVDs and am using the example script in the script help section of this website (which uses the barcode/UPC to do a lookup to the Internet to get the product details). What I would like to do is to have a button on the form to trigger the script (rather than having to select it from the menu, which I feel is less intuitive/convenient), but I don’t think this is possible? (I would love that as an enhancement!). I’ve read a few forum posts on the subject of script updating and aren’t sure what it’s best to do. Since the service used for the lookup is limited re. the number of lookups (for the free service) I want to limit the quantity of lookups, i.e. I was thinking of writing per field scripts that returned the specific value based on when the barcode/UPC value changed, but this would increase the number of lookups. Also I would like to be able to choose when to do a lookup, hence the desire for a button/trigger. Thanks in advance.

    #33061
    Aeron Manabo
    Participant

    Hi,

    I am currently interested with the scripting capability of TapForms to apply on my workflow. I would like to ask for help or maybe scripting samples for this conditions:

    1. To Create a New Record.
    2. To Put the Current Date in a Date Field.

    (Much better if I am able to have a prompt to input details to specific fields [e.g. date, week number, etc.])

    Thank you so much for your help on my learning journey. :)

    #33060
    Brendan
    Keymaster

    Hi Ian,

    I have a fix for that coming in the next update. Sorry about that.

    It’s doing that only if you’re editing a Script field. It doesn’t crash when tapping that button when editing a Form script.

    But all it will have in there is the Run Script command which you can access by tapping the run button on the toolbar above the keyboard.

    Thanks,

    Brendan

    #33058
    Ian Heath
    Participant

    Hi, A newbie here, just purchased this today on iOS and planning to get the macOS version very soon. First impression is very good. No doubt I will have some other questions but my first one is a consistent crash I can cause.

    It’s when I’m looking at a script in the forms view and select the option in the screenshot (top right of screen).

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

    Hi Peter,

    This is because in a Link to Form field there can be multiple child records. So which record are you trying to reference? The Calculation field doesn’t let you reference individual records from a Link to Form field. You can only get an aggregate result. For Number, Calculation, and Rating fields, you can get the Total, Average, Minimum, or Maximum value from the child records for the specified field.

    You will need to use a Script field instead to be able to reference a specific child record from a Link to Form field. Something like:

    function getFirstProjectName() {
       var projects_field_id = 'fld-....';
       var project_name_field_id = 'fld-....';
       var projects = record.getFieldValue(projects_field_id);
       var firstProject = projects[0];
       var projectName = firstProject.getFieldValue(project_name_field_id);
       return projectName;
    }
    
    getFirstProjectName();

    Thanks,

    Brendan

    #33020
    Victor Warner
    Participant

    I am creating a database to record subscriptions and have set up fields to show

    1. name of subscription;
    2. period of subscription (yearly, monthly, 2 yearly);
    3. type of subscription (eg work, domestic, software);
    4. amount of subscription

    among others.

    I can see that one of the options is to group records. If I choose type of subscription and Multi-Column View then I can group on headings for work, domestic, software and choose and as a sort field type of subscription so that within each heading the subscription are sorted by the period.

    As far as I can work out it appears is not possible to have 2 level Group by Records.

    For example, rather than having

    Work
    domain registration,2-yearly,£9.99
    tap forms, monthly, £150.00
    365 office, monthly,£59.00
    office insurance,yearly,£300.00
    professional indemnity insurance,yearly,£1,500.00
    Total £2,108.99

    Instead:

    Work
    2-yearly
    domain registration, £9.99
    £9,99

    monthly
    tap forms,£150.00
    365 office,£59.00
    £209.00

    yearly
    office insurance,£300.00
    professional indemnity insurance,£1,500.00
    £1,800.00

    £2,108.99

    Is this type of 2-level grouping available in Tap Forms?

    #32954
    David Salgueiro
    Participant

    Hi Brendan,

    I’ve noticed a couple of weird things while building my first Form script. Not sure if I’m just being a noob (probably am).

    Does alertWithMessage stop execution? Is this intended behaviour? If so, is there an alternative that won’t halt execution on iOS? Example:

    Utils.alertWithMessage('test', 'this message will display');
    Utils.alertWithMessage('test', 'this message will NEVER display');

    Also:
    Utils.alertWithMessage('test', '0 time: ' + new Date(0));

    Displays:
    test
    0 time: Thu Jan 1 1970 00:00:00 GMT+0000 (GMT)

    However, if I assign that value to a blank date field, formatted to display as HH:mm, with Set Current Time as OFF, using the code:
    record.setFieldValue(test_time_id, new Date(0));

    I get a value of 01:00, when I would expect a value of 00:00.

    If I adjust for it, with the code:
    record.setFieldValue(test_time_id, 0 - 60*60*1000);

    … then I get the value of 00:00.

    (I seem to remember an old TF bug similar to this many, many moons ago — I wonder if it has come back to haunt :) ).

    Thanks for your help, as always.

    Merry Christmas!

    #32911
    neo x
    Participant

    i would like to have an inventory database. 2 forms. 1st for the parts themselves. part #, description, and quantity on hand. 2nd form for transactions. receive a part(s) which adds part with specified quantity, use a part which subtracts it . i have this form with datetime, part number which i want to link to first form and update that quantity, num of parts used or added, why field which has picklist for use, received, transferin, transfer out. i’m not sure how to set up link to type. i would like to take number on hand on first form and update it with quantity changed on second.

    #32783

    In reply to: Count unique records

    Brendan
    Keymaster

    Hi Ted,

    There’s no JavaScript API to update the list of values in a Pick List. But you could do this with a Many to Many Link to Form field. You could have a Bus form that has a Link to Form field connected to an Available Seats form. Then when you click the checkmark button to add a seat to the Link to Form field on your Bus form, Tap Forms will show you only the records that haven’t been linked yet.

    So maybe that’ll help.

    Thanks!

    Brendan

    #32767

    In reply to: Count unique records

    Ted
    Participant

    Is this how I would get a pick list that removes an option that had previously been selected?

    Example: allocating seats on a bus – you can’t sell the same seat twice for the same trip.

    Or is there an easier way without messing with Java Script?

    #32645

    In reply to: Count unique records

    Brendan
    Keymaster

    Hello Krys,

    It depends on what you mean by “unique”. Is there a particular field which defines a value that may have duplicates in it that you want to count the number of unique values for?

    You could do that by writing a Form Script which loops through all the records in your form, getting the value for that field and counting the number of unique values. You could add the value to a JavaScript Set which would guarantee that only unique values are added to it. Then you could just get the size of the Set.

    See this link for info on Sets in JavaScript:

    https://alligator.io/js/sets-introduction/

    Thanks,

    Brendan

Viewing 15 results - 2,536 through 2,550 (of 2,864 total)