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 - 706 through 720 (of 2,951 total)
  • Author
    Search Results
  • #48370
    richard maliszewski
    Participant

    I know that in multi-column view, I can view the summation (and other stats) for any column using the sigma “row” at the bottom. I can also set the “calculation” for a form to a field and type.

    I’d like to use the total of a column as a script trigger. It looks like to do that, I’d need the field ID for that value. Is that field ID per form immutable, and is there a way to get at that?

    –Richard

    richard maliszewski
    Participant

    And there may be no joy in Mudville. My hope was that this parent form would have summations for multiple envelopes. Naively, I expected that the “Link to Form” field was a per record field, since it’s, well, a field. But thus far, it appears that changing that field for one record in the parent form changes it for all records…so it’s effectively a form property, and not a field value. I can see why allowing multiple joins would be problematic, but it’s not as clear that having a per record one-to-many would bring down the house.

    Is there a workable supported route for what I am trying to do? It’s starting to look like the parent may have to have a per-envelope aggregation script. Javascript is not my language of choice, but it looks like there’s enough functionality to do this without having form-to-form relational doings.

    –Richard

    #48356
    Brendan
    Keymaster

    You can use a Script field to concatenate values from your Link to Form field together. Build an array of values, then use array.join(", ") to join them into a single comma separated string. Or however you want to join them.

    #48352
    Lane Robinson
    Participant

    Thanks for that. That looks like it should accommodate when I need text and not a number. And I fully get having non programmer functions be the face of access. And also, thank you for participating in a forum such as this with people learning the ways of Tap Forms. It’s very helpful.

    Looking up data from a field in another form is something I will do a lot. In the long term, I believe I will likely write some javascript that gives me what amounts to a field type I might call “Lookup”. For this one project, I’ll be satisfied however I can make it work.

    In looking at the Formula for a Calculation field type, I had expected when I move a field to the formula area I would be offered text related functions in a function popup similar to when it’s a number I move. All that is available is COUNT for text. So it looks like when from another Form, the field that is moved over is an array of values. Because the Form I’m calling from is a field with a Link to Form type using Join, it should always be an array with a count of 1, since Ad Sizes will only ever have unique values in each record. So even if I could have a CONCAT of array values, that alone would be very helpful. Or a way to access individual elements of that array. Or even just the first element.

    Anyway, that’s just food for thought for something I would find very valuable. Thank you again.

    cheers,
    Lane

    #48343
    Brendan
    Keymaster

    So Tap Forms was designed to take SQL out of the picture for customers. So things like searching are done by creating Saved Searches using the UI.

    You could build a Saved Search on your AdRates form that filters on size equals 'full page'.

    Then in your Script, ask the Form for the Search with whatever search name you assigned:

    var adsSearch = form.searchNamed('Full Page Ads');

    Then you could simply grab the first record from the array of records returned from the search.

    var firstRecord = adsSearch.getRecords()[0];

    Now you can get the value for the field from the firstRecord:

    var price = firstRecord.getFieldValue(price_id);

    Something like that at least.

    Thanks!

    Brendan

    #48332
    Daniel Leu
    Participant

    So in the ad-rates form, you have one record that defines all the different prices?

    I would change this to one record per size. Then you can use a joined link-to-form field to link the two records based on the size. Next, use a calculation field to fetch the pricing from the linked form. No javascript needed.

    Cheers, Daniel

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

    #48331
    Lane Robinson
    Participant

    I tend to think in terms of sql when it comes to databases. How would I translate an sql query sort of like this into a script where the script is in one Form and adrates is separate Form.

    SELECT price FROM adrates WHERE size = ‘full page’ limit 1;

    #48329
    Lane Robinson
    Participant

    OK. I’m committing to using javascript for this. Just when I think I’m out they pull me back in!

    When using a script, do I do it something like this?

    select a record from my Ad Rates form where Ad Size = the value of Ad Size on my Orders form? And then get the value of the Ad Rates field on the selected record?

    reading the API right now.

    • This reply was modified 2 years, 11 months ago by Lane Robinson.
    #48328
    Lane Robinson
    Participant

    OK. So a multi field fill instead of a lookup. A table is basically like a form, but a sub form of its parent form. It’s always going to be a table with a single row in this case. And I guess I can’t sort a layout by the ad size field in that table, which I need.

    So I’m trying to pull data up to the main form using a calculation. I can see how I can do a total of the ad price from the table onto the main form. But I can’t seem to get the ad size out. I’ve tried using a concat. All it seems to allow is a count, which is auto inserted with the field when I move the field into the Formula space. Trying to change this to a concat isn’t understood.

    It’s not ideal that I would use a calculation for this anyway, as I may need to override or otherwise enter a custom value. I can live with it if it has to be a calculation. Would so much prefer an autofill I can change.

    Would a script allow me to manually overwrite a value it returns? I wouldn’t think so. Perhaps I could add an ‘override price’ field the script would read from and return. Awkward looking, but would do the job.

    #48327
    Brendan
    Keymaster

    The nice thing about JavaScript in Tap Forms is that you don’t have to worry about all of that DOM junk you have to deal with when writing JavaScript code for a web browser.

    Here’s a simple example:

    function countPhotos() {
       var photo_id = 'fld-....';
       var photos = record.getFieldValue(photo_id);
       if (photos != undefined) {
          return photos.length;
       } else {
          return 0;
       }
    }
    
    countPhotos();

    Not too bad if you’ve got some sort of programming background. And even if you don’t there’s plenty of examples on this site you can learn from.

    #48325
    Brendan
    Keymaster

    The Table field is a good use for this sort of thing.

    Take a look at the Invoices sample template:

    https://www.dropbox.com/s/6rkk6413cbv3aj1/Invoices.tapforms.zip?dl=1

    In there you’ll see an Orders form that has an Order Items Table field in it. The Order Items field is connected to the Products form. When you click the checkmark button to choose a record from the Products form, Tap Forms will copy multiple fields from the Products form into the Order Items Table field, including the product name and price.

    Another way to do it is to use a Script field that fetches the value you want from another form. But that’s a bit more complicated to achieve.

    #48323
    JB Be
    Participant

    Thanks, Patrick, for taking this up. I admit that scripting is to hard for me (although I gave it a try). Getting a menu command as you described would save my investment in TF… :-|

    #48313

    Topic: Date comparison

    in forum Script Talk
    Ian Wheeler
    Participant

    Hi Folks,

    I am trying to check via a script whether a Date field contains a date that is earlier than today. If it is then I want to delete the record. Ideally this would be a manually run script. I am very new to TF (and loving it, and am in the process of migrating over from Filemaker) and Javascript. Below is the script that I have which just doesn’t work. I suspect it is my Date comparison element that is the problem as the Console.Log isn’t detecting any errors, but I don’t know how to fix it. Any help would be greatly appreciated

    function Delete_Expired_Docs() {
    
    	var records = form.getRecords();
    var field_id = 'fld-46f16c00d13344e79478a8b629022ee7';
    	
    for (var index = 0, count = records.length; index < count; index++){
        var aRecord = records[index];
        var field_value = aRecord.getFieldValue(field_id);
        if (field_value < Date()) {
            form.deleteRecord(aRecord);
        }
    }
    
    form.saveAllChanges();
    
    console.log(field_value);
    console.log(count);
    console.log(Date());
    
    }
    
    Delete_Expired_Docs();
    • This topic was modified 2 years, 11 months ago by Brendan.
    • This topic was modified 2 years, 11 months ago by Brendan. Reason: formatted code
    #48301
    Lane Robinson
    Participant

    Thanks for those comments Chris.

    So I’m a used to be programmer who hates javascript. I’ve dipped into it here and there. And while I might end up needing to use it, I am very deeply hoping I don’t need to! But at least it’s not AppleScript, which might be Dante’s ninth circle. :P

    #48300
    Chris Ju
    Participant

    I can definitely confirm that you can map really complex business processes with TapForms. With lists and Java Script support (see Java Script documentation on the homepage) you can really automate nearly everything…

Viewing 15 results - 706 through 720 (of 2,951 total)