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,081 through 1,095 (of 2,989 total)
  • Author
    Search Results
  • #46164
    Victor Warner
    Participant

    I would like to create a CSV file through a form script, as it will be much quicker/more automated than going through the File/Export/Export option.

    I have been able to create a script which uses Utils.copyTextToClipboard() to get the data out (and then using the clipboard to insert it into an AppleScript). It appears to work, but was wondering whether it is also possible to write the data to a file rather than the clipboard?

    The script as far as I have got with it:

    var client_name = record.getFieldValue('fld-ffa7651ff5bd48a9aa8184a69be8550e');
    var email = record.getFieldValue('fld-152d99920304499f8f89c3868eb144d1');
    var details = record.getFieldValue('fld-23c8168c1deb45bfbcabc862ad6e5199');
    var date_prescribed_information_provided = record.getFieldValue('fld-0bf58a5d40b3430f8745b86b2a49775a');
    var document_details = record.getFieldValue('fld-b8a4b0731dc94f46abf28eab828abc4e');
    var number_of_documents = record.getFieldValue('fld-7ba7df82977945988aac2598dc528a75');
    var amount_of_notary_charge = record.getFieldValue('fld-648fee2d0eaa4e7d973fe86bde1d504f');
    var what_will_third_parties_be_providing = record.getFieldValue('fld-abfb6ffd2c7c4695972ed54ec463fc08');
    var third_party_charge_plus_charge_to_arrange = record.getFieldValue('fld-8cc4031614d7402aa5e131d33ae1c039');
    var final_charge = record.getFieldValue('fld-6b86691517dc4b8b8efa63b7da98185d');
    var second_individual_client_name = record.getFieldValue('fld-772ee93b5eb747d294e5a9a7b548ebda');
    var second_individual_email = record.getFieldValue('fld-d09998df75864a0e8f82b6f61188b537');
    
    // set email for prescribed information document
    
    if (second_individual_client_name){
    var email_for_prescribed_information = email + " and " + second_individual_email;
    } else {
    var email_for_prescribed_information = email;
    }
    
    var date_formatted = date_prescribed_information_provided.toLocaleDateString("en-GB", { year: 'numeric', month: 'long', day: 'numeric' });
    
    var lines = client_name + ";" + email_for_prescribed_information + ";" + details  + ";" + date_formatted + ";" + document_details + ";" + number_of_documents + ";" + amount_of_notary_charge + ";" + what_will_third_parties_be_providing + ";" + third_party_charge_plus_charge_to_arrange + ";" + final_charge + ";" + second_individual_client_name + ";" + second_individual_email;
    
    //	Utils.copyTextToClipboard(JSON.stringify(record.first_name_id));
    	
    Utils.copyTextToClipboard(lines);
    #46162
    Daniel Leu
    Participant

    No, the variable form revers to the current form where you call the script from. If you want to add a record to a different form, then you first have to do a

    var myForm = document.getFormNamed("My Form Name");

    And then you would use myForm instead of form.

    Cheers, Daniel

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

    #46159
    Brendan
    Keymaster

    The Apple Watch version of Tap Forms is read-only. So that’s why you can’t add a record from the watch. The scripting idea is good. Something like this:

    function addNewRecord() {
       var new_record = form.addNewRecord();
       // do something to the new record if you want, such as calling new_record.setFieldValue(field_id, "some value");
       form.saveAllChanges();
    }
    
    addNewRecord();
    #46156
    Sam Moffatt
    Participant

    I think for this one, if the defaults make sense the form script can be as simple as “form.addNewRecord();” and then you need to enable your script for Siri (there should be a button in the editor on your phone). I think you might also need to enable the document for Siri (it’s been a while) and then you should be able to use Siri to create a new record automatically.

    #46155
    Karan Shah
    Participant

    Thank you. Any guide to scripting? I’m not a coder, but if it’s simple I’m happy to look at setting up a script for this.

    #46154
    Sam Moffatt
    Participant

    I think what might work for this is to enable Siri for your document and then create a script that creates a new record. Then you can use either a Shortcut or Siri directly to create a new record with the current date and time.

    #46150

    In reply to: Help with if statement

    Sam Moffatt
    Participant

    To expand a little, second_individual_client_name.length===0 is failing because if the field isn’t set to a string value, it’s an undefined value or null. The .length only works if second_individual_client_name is set to a string but if the field isn’t entered, Tap Forms returns a null/undefined value to signify the difference between a field with an empty string and a completely unset field.

    Javascript has the concept of “falsy” values that are values that evaluate to “false” when used in an if test situation. In this case not only is null and undefined a “falsy” value, but an empty string is also a falsy value. This means that for your purposes, that is to say to check if the field has a value, this simple if test does what you need without validating the length.

    [1] falsy: https://developer.mozilla.org/en-US/docs/Glossary/Falsy

    #46148
    Victor Warner
    Participant

    I wish to create a script to deal with the following where the document contains two email fields:

    1. if only one email field (“email”) has an email address the script assigns to a variable just that email fields contact; but
    2. 2. if both email fields (“email” and “econd_individual_email”) have email addresses then the script assigns to a variable the following: “email_field_1 = ” and ” + email_field_2″
    using an if statement testing whether another field (second_individual_client_name) contains anything.

    It works fine when the other field (“second_individual_client_name”) contains data but generates an error when it does not.

    The script is as follows:

    var client_name = record.getFieldValue('fld-ffa7651ff5bd48a9aa8184a69be8550e');
    var email = record.getFieldValue('fld-152d99920304499f8f89c3868eb144d1');
    var second_individual_client_name = record.getFieldValue('fld-772ee93b5eb747d294e5a9a7b548ebda');
    var second_individual_email = record.getFieldValue('fld-d09998df75864a0e8f82b6f61188b537');
    
    // set email for prescribed information document
    
    if (second_individual_client_name.length===0){
    var email_for_prescribed_information = email;
    } else {
    var email_for_prescribed_information = email + " and " + second_individual_email;
    }
    
    console.log(client_name + "\n" + email_for_prescribed_information);
    

    The error message generated is:

    New Script: TypeError: undefined is not an object (evaluating 'second_individual_client_name.length'), line:(null)

    Any help would be gratefully received.

    #46127
    Brendan
    Keymaster

    The record object itself has a dateCreated property. It works a little differently than actual fields. When you add a Date Created field, Tap Forms handles it just a bit different because the value is stored on the record object itself and not inside the list of field values.

    If you have a separate field that has your creation date values, then you could modify your script to copy the date value into the dateCreated property.

    var date_value = record.getFieldValue(field_id);
    record.dateCreated = date_value;

    Then form.saveAllChanges();

    That should work.

    #46093
    Andreas .
    Participant

    Hi,

    to avoid possible data loss I imported all my data as text (unfortunately there is doesn’t seem to be an import log).
    Now I converted everything successfully by some scripts.

    I am just not able to update the creation date using the internal corresponding field type.
    Is there a way to keep my original dates ?

    best
    Andreas

    #46092
    Andreas .
    Participant

    Hi Brendan,

    that’s right – I address the saved search from a script and it needs to be internal accessible. I just want to hide it as it is not meant for be for users use.
    Whether it would make more sense to have the feature at a searved search itself of at the level of a folder would have to be thought over again in detail.
    A folder solution would of course give more structure at the same time.

    best
    Andreas

    #46087
    Brendan
    Keymaster

    Hi Andreas,

    Thanks for the feature request. So you want to hide a search folder and not a Saved Search itself?

    Are you using the Saved Search in a script? So you still need the search to be accessible by the Script but not selectable?

    FYI, Saved Search results list doesn’t get updated until the moment you actually click on them to view the results.

    #46083
    Rob Griffiths
    Participant

    Hello, I’m a newbie evaluating Tap Forms, and so far, it looks like it will almost perfectly meet my needs. However, I’m having trouble doing something that’s simple in pretty much any other spreadsheet or database I’ve used…

    I have a form that tracks subscription costs, which can be per month, quarter, semi-annual, or annual. I want to show the annual cost, so I tried this calculation field:

    [PER_TERM_COST]*IF([TERM]=”Annual”;12;IF([TERM]=”Semi-Annual”;2;IF([TERM]=”Quarter”;4;12)))

    It failed miserably. After some testing, it looks like Tap Forms doesn’t support using string tests in if-then statements at all—is that correct? The only workaround I found, which is ugly but does work, was to do it on string length:

    [PER_TERM_COST]*IF(LENGTH[TERM]=5;12;IF[LENGTH(TERM)=6;1;IFLENGTH(TERM)=7;4;2)))

    This means I can’t ever have two terms with the same length :). Am I missing something, or is there really no string comparison support in Tap Forms?

    Obviously, I can change my term field to be a numeric value, but I like the appearance of text instead. And I realize I could have a calculation to display the text-based term, but I’d still need the numeric field visible for input. String-based comparisons would add a lot of power to Tap Forms, assuming it’s not there and I’m just missing something.

    thanks;
    -rob.

    #46008
    kim kohen
    Participant

    Now that I have it working, there’s a couple of things I’m going to try to add.

    1) A due date field which would be 30 days (or whatever the payment term) past the invoice date. Ideally when now() > due date the invoice record could change red (as per one of Sam’s videos). It would allow for easy follow up of overdue invoices.

    2) I’ll add ‘Invoice number’ and ‘Payment Date’ fields to the Consultation form. When an invoice is created the invoice number would copy to the Consultation records. Once an Invoice is paid a script would copy the payment date to all the appropriate consultation records which would essentially ‘close’ the transaction.

    #45981
    Sam Moffatt
    Participant

    I could see a debug mode option to prefix the lines with the script that the log message was coming from, I struggle with that with errors from time to time figuring out which library actually choked. I’m not entirely sure that’s actually possible due to how I understand the JSC integration works because it’s not obvious the context you’re calling from includes the layers of parser or not.

Viewing 15 results - 1,081 through 1,095 (of 2,989 total)