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 - 841 through 855 (of 2,989 total)
  • Author
    Search Results
  • #47588
    Lars Mathiasen
    Participant

    Hello. I am new to TF. I have made a training app using iCloud for DB sync. Now I want to migrate it to a cloud solution like IBM or Apache DB. However, I do not get how to manage users in TF and external DB’s. Are there some man-pages or some videos on the topic so users can have private forms and share forms like premade information?

    My model is to have users add them-selves on a logon/register page I make in HTML. They buy TF for iOS and get access to training descriptions, recipes and training log.

    #47581

    Topic: Date issue

    in forum Script Talk
    Stig Widell
    Participant

    Hi,
    In the form “Rekryteringsdjur” I have the field “Senaste kalvning, datum” (latest calving date)
    which is created by a script.
    Now I tried to add a new calculation field “… och betäckt, datum” (pregnancy date) but it works for some cows only and not for others and in the iphone it doesnt work at all.
    Need help!

    Attachments:
    You must be logged in to view attached files.
    #47547

    In reply to: Feature or Fluke?

    Daniel Leu
    Participant

    I use this whenever I need a function from my ‘script library’. I don’t care if the script is called several times. But I protect the content of these library scripts so they are not executed more than once. Here is the example of my Common script:

    // Only define functions once and skip them when already called
    if (typeof commonScript === undefined){
    	var commonScript = 1;
    
    // here go your function definitions
    
    }

    Obviously there is a performance penalty when you have many script fields that use this include and you do a refresh of *all* records.

    But yeah, sometimes it is a challenge to get a field script trigger upon a field change… I run into this as well… I usually try to have all field defines at the top of the script:

    var fldName = 'fld-xxx'
    ...

    And then in the script I just use these defined variables or constants.

    Hope this helps!

    Cheers, Daniel

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

    #47533

    In reply to: Feature or Fluke?

    Bernie McGuire
    Participant

    Daniel, This is a great idea. A question , when you say “Then in the field script, I use document.getFormNamed ..” You put this in the first field script on the other forms so they can execute the functions in ‘Common’, correct?

    Do you get this first field scrip to execute automatically (by watchin a field on the form) ? or does your user have to do ‘refresh’ to get things started? I am having a very hard time getting a script to run automatically, based on a field change, I have dried a dozen ways. I need to have the user hit ‘refresh’ How do you do it ?

    Thanks for you help
    Bernie

    #47528

    In reply to: Feature or Fluke?

    Daniel Leu
    Participant

    I usually create a form named Scripts and place all javascript functions in form scripts (eg, Common). I try to organize them logically so I can easily reuse them. Then in the field script, I use document.getFormNamed('Scripts').runScriptNamed('Common'); to load one (or several) of these form scripts. Later I can execute whatever function I need.

    • This reply was modified 3 years, 7 months ago by Daniel Leu.

    Cheers, Daniel

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

    #47524

    Topic: Feature or Fluke?

    in forum Script Talk
    Bernie McGuire
    Participant

    I have a situation which I don’t know if it works because of TF design or just happens to work now and maybe will not in the future.

    I have a ‘Result’ field , on a ‘Entry Form’ , that can have 17 different values. I use a pick list to have the operator populate the field.

    On the ‘Totals’ form I want to show a count (and percentage) of each result value. So I have a script that will loop througe the records on the linked ‘Entry Forms’ and count the ‘Results’. This script function takes an input parmater containe the ‘Result’ value I want a total for and return the appropiate value.

    So rather than duplicating the script in 17 different total fields I placed the script (named CountResults) in the FIRST field on the Totals form, and then for the other 16 i just execute ‘CountResult(‘xxx’)

    This only seems to work if the script (CountResults) is in the first field on the totals form.

    So, is this a feature I can rely on now and in future releases, or not?
    (I understand the risks if the script field changed location, etc.

    Thansk
    Bernie

    #47509
    ang
    Participant

    Hello,

    I’m trying to display the value of a specific field value from a linked parent form (many to many).
    Name of the parent form : “structures_19_06”
    Field ID value to display : “fld-33b8d7ca30f54c7f8e9974030ea1b3f0”

    In script, i have added the field like this :

    function Structure_Diffuseur_1() {
    var nom_de_structure = structures_19_06[index].getFieldValue(‘fld-33b8d7ca30f54c7f8e9974030ea1b3f0’);
    }
    Structure_Diffuseur_1()

    It returns thos error :
    Structure (DIFFUSEUR) 1: ReferenceError: Can’t find variable: structures_19_06, line:(null)

    Can you help me to correct this ?
    Thank you very much

    #47481
    David Schwane
    Participant

    one last related question. I notice if I refresh all records, the script is getting fired and incrementing the field by 1 each time. Is there a way to bypass the script trigger from record refresh?

    #47474
    Daniel Leu
    Participant

    Something like this:

    const fieldWebSite = 'fld-...'
    const fieldWebSiteClean = 'fld-...'
    
    var web_site = record.getFieldValue(fieldWebSite);
    var new_web_site = web_site.split('?')[0];
    record.setFieldValue(fieldWebSiteClean, new_web_site);

    Re Times Used:
    I’m not certain that this works, but I think to remember that the field trigger code parses the script for fld-... patterns. So when using const fieldTimesUsed = form.getFieldNamed('Times Used').getId(), you might avoid the trigger. Certainly @Brendan will chime in on this.

    Cheers, Daniel

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

    #47470
    Daniel Leu
    Participant

    Yeah, the script is triggered again if you update it with your script. In situations like this, I use two fields, one with the raw data and one with the processed data.

    Cheers, Daniel

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

    #47468
    David Schwane
    Participant

    Thank you and I understood that is the current mechanic, but for me, the script fires twice because I suppose I’m changing the field that I’m watching. While this looping doesn’t cause an issue with this example, I have some other situations where the script firing twice is problematic.

    Example attached.
    import
    open console
    copy into website field a URL with query string, i.e https://example.com/movies?si=zyH0Aqaaa

    console shows
    Script Excecuted 6/8/2022, 7:32:50 PM for https://example.com/movies
    Script Excecuted 6/8/2022, 7:32:50 PM for https://example.com/movies

    Attachments:
    You must be logged in to view attached files.
    #47467

    In reply to: Pictures for printing

    Brendan
    Keymaster

    Right now you would need separate photo fields to be able to print an entire sheet with different photos on it.

    As for referencing photo fields from a Calculation field, that’s not possible. But you can access the list of photos from a Script. But not the actual photos themselves. Just the metadata around the photos. Useful for building saved searches that might want to show only the records that are missing a photo.

    #47459
    Brendan
    Keymaster

    As Daniel said, and you can also hide the Script Field from displaying on the form. It will still activate when the field is changed in the UI.

    #47452
    Daniel Leu
    Participant

    Create a field with the type script and put it there. It will only be executed when the field web_site changes. At the end of the script, add a form.saveAllChanges().

    Cheers, Daniel

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

    #47451
    David Schwane
    Participant

    How do I implement field data scripting wihout looping? I understand field scripts and fields are watched via adding the field id. But how do I watch a field, change its value, and not cause a loop? I’m used to event driven functions where I could choose pre or post save, etc.

    Example:
    URL Field; If someone enters a URL with a query string, I want to strip out everything after the question mark. Where do i put this script?
    var web_site = record.getFieldValue('fld-xyz');
    var new_web_site = web_site.split('?')[0];
    record.setFieldValue('fld-xyz', new_web_site);

Viewing 15 results - 841 through 855 (of 2,989 total)