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 - 1,876 through 1,890 (of 2,952 total)
  • Author
    Search Results
  • #40581
    Sam Moffatt
    Participant

    There is a search.getRecords() to get records from the current search. It has a few methods, checkout the JavaScript API page for more details (towards the bottom of the page).

    #40578
    Victor Warner
    Participant

    On running this script it works on all the records in a database.

    Running the script on a filtered set of records (through Find (Command + F) or an Advanced Search) does not limit its operation to the filtered set of records.

    Is it possible to make the script work only on a filtered set of records?

    #40576
    Brendan
    Keymaster

    By the way, you have to replace the field IDs with your own proper field IDs.

    But since you used Sam’s idea and switched to a One to Many Link Type, then you could also simplify the above script to:

    function getCompany() {
    
        var company = '';
        var contact_record = record.getFieldValue('fld-abc123.......');
    
        if (contact_record) {
            company = contact_record.getFieldValue('fld-xyz987......');
        }
    
        return company;
    
    };
    
    getCompany();

    By the way, I’ve just typed in this code and haven’t actually run it since I don’t have your form. So it might not work out of the box.

    #40575
    Brendan
    Keymaster

    For the Child Records Loop snippet to work properly, you need to first select a child field from the Fields list on the Script Editor.

    Then double-click on the Child Records Loop snippet.

    You’ll get something that works then.

    However, since you have a many-to-many relationship, you have to think about which customer record you actually want. The Child Records Loop snippet will loop through all of the child records. The // do something comment means this is where you want to do some custom programming.

    But in your case, if all you want is the first record, then you don’t really need the loop itself. You can just grab the first child record.

    So something like this:

    
    function getCompany() {
    
        var company = '';
        var contact_records = record.getFieldValue('fld-abc123.......');
    
        if (contact_records.length > 0) {
            var first_contact = contact_records[0];
            company = first_contact.getFieldValue('fld-xyz987......');
        }
    
        return company;
    
    };
    
    getCompany();
    

    So this will pick out the very first record from the contacts Link to Form field and return the company. It will appear in your Company Script field.

    I hope that makes sense.

    #40574
    David Oxtoby
    Participant

    Thank you, i also tried Sam’s suggested about reversing the way i’m linking, and it gets me the desired result of the company name etc in the summary side-panel, so thank you for that. But having the code snippet would be great as well, if nothing else, as an aid to help me learn how to use the scripting, as this looks to be a great feature with loads of potential, once i get my head around it. Thank you everyone for speedy and helpful response.

    #40571
    David Oxtoby
    Participant

    Thx for that Sam, i’m a bit new to the whole scripting thing, i see how to make the Company field into a script field, and then add in the snippet of code for Child Records Loop, but if gives me the following the editor.

    function recordsLoop() {
    
    	var parent-field-name_id = 'parent-field-id';
    	var booking_date_time_id = 'fld-8fb5dadd45ee4276b4813669aeef34e3';
    	var parent-field-name = record.getFieldValue(parent-field-name_id);
    
    	for (var index = 0, count = parent-field-name.length; index < count; index++){
         	var booking_date_time = parent-field-name[index].getFieldValue(booking_date_time_id);
    		if (booking_date_time) {
    			// do something
    		}
    	}
    	return;
    }
    
    recordsLoop();

    how do i then tell it to loop through my customer form/table to pull out the first record Company Name?

    sorry to ask the basics on this, but it’s a long time since i programmed, and back then it was COBOL! eek showing my age.

    #40568
    Brendan
    Keymaster

    Hi Vera and Chris,

    Thanks so much for your vote of confidence for Tap Forms. I am pretty much always working on Tap Forms new features and bug fixes. I’ve been working on it since 2008. So it’s been around a long time and I never tire of it. Sure I take a day off here and there from working on it, but I always respond to customer emails and this forum every day. Often at night after my family has gone to sleep. Especially during this time when everyone is around, it’s sometimes tricky to get time to work during the day. But I’m a night owl anyway, so this works for me. I imagine I’ll still be working on Tap Forms for the next 20 or 30 years!

    I’m glad that you were able to make a solution with Tap Forms that works for you.

    The use of JavaScript as a scripting engine was a decision I made because JavaScript is relatively easy to learn and program, and it’s built-in to macOS and iOS. Building your own scripting engine is a massive effort that a one-person operation like myself just couldn’t possibly do in any reasonable amount of time. FileMaker would have built up their scripting engine over many many years with a big team of engineers working on it. Since Apple already provided the JavaScript Core Framework, I chose to use that. So far it has worked out very well for Tap Forms, even if there’s a bit of a learning curve for some people. The snippets that I have can really help you to learn some of the basics of what you need in Tap Forms to get going. Plus the Script Talk forum on my website can be very useful to see how other customers are writing scripts. And there are some fabulous customers and Tap Forms beta testers on that forum who really know their JavaScript stuff.

    Thanks!

    Brendan

    #40566
    Sam Moffatt
    Participant

    If you make Company a script field, you can use the Child Records Loop to iterate over the Customer Link to Form and extract the name. The reason is that you can technically have multiple customers so you need to iterate overall of them and process them.

    That said I’d probably flip the model a little. You’ve got a Link to Form there and I’m guessing it’s a many to many or M:M type. If for a given venue booking there is only one customer, I would recreate the field as a Link to Form One to Many (1:M) going from the Customer form to the Bookings form with show inverse relationship ticked. What this will do is change the type of control you see on your booking form to be the single record selection layout which may or may not be desirable for you. It’s like the single column list view sort of rendered into your form. The advantage of flipping the relationship is you can easily use a calculation field to pull out records. Since the booking record will only ever have a single parent, you can create a calculation field to pull the parent record’s values out (or multiple calculation fields for each field you care about). Make sure when using a calculation field to update the default output type from number to text otherwise it’ll appear empty and you won’t know why.

    #40565
    David Oxtoby
    Participant

    Thx Brendan, i’d assumed i needed a script, i just wasn’t sure how to even start referencing the form/records in the linked form to pull out one of the values, any pointers would be great. Thank you

    #40563
    Brendan
    Keymaster

    Hi David,

    If you have a One to Many Link Type from Customer to Venue, then you can enable the Show Inverse Relationship option and you can get one customer to display on your Venue layout.

    However, it looks like you probably have a Many to Many relationship. Is that required?

    The only other way to get the customer information to appear in the parent field is to use a Script and pull out the first Customer record and populate the field on the parent form.

    Thanks,

    Brendan

    #40557
    Vera Milosavich
    Participant

    Thanks Chris. I knew I wasn’t the only one who felt that way, and I was also disappointed by FM’s competition — such as it is. TapForms has been the least formidable aside from it’s use of javascript.

    It’s also encouraging to know you’ve had such success. I hope for the same. I had no trouble with FM’s scripting and formulas but I’m totally at a loss when it comes to javascript, and I know I’ll need that for my solution. I’m more than willing to try, but I’ll have no choice except to rely on this forum for help with that.

    #40552

    In reply to: Invoicing

    Vera Milosavich
    Participant

    That sounds promising. My current Filemaker db has 3 or 4 linked tables and 14k+ records in the largest table, accumulated over 5 years so roughly 2k new records are added each year. But that rate may increase in future years. It’s about 20mb now which is nonexistent compared to yours! I have no attachments but (combined amongst all tables) hundreds of fields, calculations, scripts (no JS!), and layouts — many of which I would eliminate if I retool for TapForms.

    Aside from the upgrade cost of $540, my next biggest issue with FileMaker is that it has a crippled mobile app with no iCloud support nor import abilities. I can modify records and create new ones on the mobile app, but the hassle of transferring it back to my desktop to do monthly imports for invoicing isn’t worth it. So I basically use it as a read-only app which is better than nothing, but just barely.

    If FM weren’t so expensive, I would upgrade and live with the lack of iCloud support and importing capabilities on mobile. But with those three whammies, I’m not happy. Even if I have to rebuild a stripped-down version and struggle with the learning curve, as long as TF can do the minimum of what I need, I think it’ll be more practical for me to switch over.

    I understand TF for iOS has iCloud sync support. I don’t know if it can import CSV files, but as long as it can sync, I can live with that.

    Thanks for the info on record capacity!

    #40543
    Vera Milosavich
    Participant

    This is an extract of a setup I have and the simple problem I’ve been trying to solve:

    I have two linked dbs with the following relevant fields (and field types) set up:

    1. TRANSACTIONS (has many records with the same Month/Year): Month/Year (calculation:text); Invoice (script:number); link_Invoice (link to form:join where Month/Year matches in both dbs)
    2. INVOICES (Month/Year will be unique to each record): Month/Year (text); invoice number (number)

    I want the Invoice field in TRANSACTIONS to display the Invoice Number from INVOICES where Month/Year matches so I used this script:

    var invoice_number = link_invoice[index].getFieldValue('fld-8b601a885fab4ddca84e44bed77e8bc5');

    I didn’t key in anything. I only selected the snippets I wanted then double-clicked the field I wanted from under the section with the link I set up. I get this error when I run the script in the editor view:

    5/11/20, 4:11:06 PM / Paypal Imports (405) / Invoice-script
    Invoice-script: ReferenceError: Can't find variable: link_invoice, line:(null)

    I used Join as the link type, but I tried the others with no more luck. I can’t tell what I’m doing wrong because I can’t decipher the script.

    I’m hoping it’s something simple…… although I’m officially beyond simple with my nonexistent javascripting abilities!

    #40541

    In reply to: Invoicing

    Vera Milosavich
    Participant

    Thank you, Sam. What I have is nothing as far as scripts go. I’ve tried using what seems to be the simplest snippet (get field value) but can’t get it to display the results:

    var month_year_cart_item = record.getFieldValue('fld-66ac9ba074134a8598ae601cc72a1eb7');

    As soon as I get a chance, I will post a description and diagram of the system I’m trying to develop. If from that information you can show me the script for creating summaries, and where it goes (and maybe tell me what each element of the script does?), I might be able to figure out some of the rest on my own.

    Thanks again!

    #40533
    Brendan
    Keymaster

    Hi Vera,

    Is there anything that’s common in your form for the 10-50 entries each day the that you could group your records by? When you set the First Sort Field to a Date field, Tap Forms automatically groups them into Month, Year sections.

    If you need something more fine grained than that, you would need to create a Calculation or Script field that returns the day, month, and year as a Text value.

    For example, a Calculation field with the formula:

    DATE(Item Date; "yyyy-MM-dd")

    That will return a value for your Item Date field (or whatever it’s called) and Tap Forms can then group on that field. So then all records with the same year, month, and day would all be grouped together into the same section.

    Give that a try and see how it goes.

    Thanks,

    Brendan

Viewing 15 results - 1,876 through 1,890 (of 2,952 total)