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,989 total)
  • Author
    Search Results
  • #48541
    Brendan
    Keymaster

    Scripts don’t run when you’re just browsing records. Imagine you had a script that took a long time to execute and you ran it for every record that’s displayed. It would make browsing miserable.

    So there’s no automatic way of triggering a script when clicking on a Saved Search. You would have to refresh the records list which would run every script on every record displayed.

    #48535
    Daniel Leu
    Participant

    Idea: how about assigning a keyboard shortcut to a script?

    Cheers, Daniel

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

    #48533
    Tim H
    Participant

    Thinking about this a bit more…

    Is there a way to auto-run a script based on a saved search? For example lets say I have saved a search that utilizes a rule that a particular field be non-empty. Additionally I have a saved search with a rule that specifies a field to be empty. Depending on which saved search I’m browsing records with, the script would “fire” either collapsing or expanding the section heading.

    Basically, I’ve got a long default form with a section containing a bunch of fields that I’d prefer not to see (collapse section) unless there is information in one of the fields within the section.

    Thoughts/ideas?

    T.

    #48527
    Tim H
    Participant

    Hi Brendan,

    I was able to use your bit of code and get the Section to collapse based on whether or not another field was undefined. It works great thank you!

    Now is there a way to get this script to “auto-run”? I’ve saved the script as a “form script” i.e. it’s not a script type field in the form but I have to manually run it each time. Ideally I’d like the script to run each time a different record is displayed i.e. collapsing/un-collapsing the section while browsing records.

    Thanks again for your help.

    T.

    #48526
    Brendan
    Keymaster

    The example above just toggles the section opened and closed each time you run the script. You will probably have different logic.

    #48521
    Tim H
    Participant

    I a real beginner with scripts in Tap Forms so am finding it difficult to collapse a section based on the contents of a field. Basically I’d like to collapse a section if another field is empty.

    I see from Tap Form’s JavaScript API there is something that looks like it should close a Section Heading type field (field.isCollapsed = true;) but when editing a form script the Section Heading type field I want to control does not appear in the list of Available Fields. I was able to get the field ID from the Fields List but still cannot programmatically collapse the section.

    I’d appreciate any tips on getting this to work. Thanks

    T.

    #48495

    In reply to: Conditional Fields?

    Daniel Leu
    Participant

    If you use a script, you can set the color of a record: record.setRecordColor('#cc9900');. Maybe that’s sufficient for what you want to achieve.

    Cheers, Daniel

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

    #48486
    richard maliszewski
    Participant

    I guess one way to do this would be to have the URL invoke a form script instead, with recordId as a parameter. Script could then look up the record, find the type, select appropriate layout and then select the record. Seems like that would get me where I want to be.

    –Richard

    #48462
    Lane Robinson
    Participant

    Thanks Brendan,

    I’ve found that once I’ve applied styles to a Note field I can no longer paste plain text into it. There is no error in the console about this. It just doesn’t happen.

    In the other sub forum you mentioned

    I suppose you could make a record that has the settings you want in your Note field and then duplicate that record whenever you want to make a new record? You would need a bit of text in there, even a space character for the attributed string to remember its settings.

    I’ve been trying that, but I can’t see a way to append text to it in your javascript API, and with the fact I can’t even replace it with plain text once it’s been styled is going to force me in the long run to figure out how to convert richtext into an NSAttributedString.

    I have another idea for this I’m going to explore.

    #48458
    Brendan
    Keymaster

    Hi Lane,

    record.setNoteFieldValue() requires either plain text or an NSAttributedString. However, that rich text can’t really be converted to an NSAttributedString in JavaScript as far as I know. So you’ll be better off just using plain text.

    #48457
    Lane Robinson
    Participant

    brand new to javascript, but I’m reading a lot.

    so, I have this richtext

    {\rtf1\ansi\ansicpg1252\cocoartf2706
    \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 FiraSansCondensed-Regular;}
    {\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
    {\*\expandedcolortbl;;\csgenericrgb\c0\c0\c0;}
    \margl1440\margr1440\vieww11520\viewh8400\viewkind0
    \pard\tqr\tx7117\pardirnatural\partightenfactor0

    \f0\fs24 \cf2 <placeholder>}

    I don’t quite know how to convert that to an object variable that can be used with setNoteFieldValue.

    #48455
    Lane Robinson
    Participant

    Can they not have default settings one would set in layout?

    I have unformatted text with tab characters, but no formatting otherwise. This would require a person to set the same tabs for every record when new records are imported with identically tabbed, but different data. A default set of tabs from what I’d apply in layout seems like an obviously useful thing.

    I see how I can apply styles to all records in the default layout for that note. It’s an extra step that has to be remembered, but at least it avoids manually setting this for every record.

    While I can see a box for a default value for a Note field, I don’t see how I could have default formatting with that default value. So, with javascript, can I “pre-fill” this note field with a blank Text Edit file that has tabs set as I need? I could then copy the data from another form to this one (I’m already doing this for another reason). My hope would be that copying the unformatted tabbed data will take on the tab settings from the first blank line determined by the textedit file.

    Or maybe there is a better way I can’t see yet. Any thoughts on how to best proceed to essentially make a default format of a note field?

    #48441
    richard maliszewski
    Participant

    So there’s no JS API to open another form from current form. But if you can divine a record from the hope-to-viisit form, form.selectRecord(that record) will get you to the form, and a subsequent re-invocation will get you to that record. Handy stuff to stash in a form field script.

    –Richard

    #48436
    richard maliszewski
    Participant

    Brendan, does this mean that a change to a record value referenced by its field ID in a variable will also cause that record’s script(s) to execute. For example, I have code that looks like:

    var transAmtFldId = transAmtFld.getId();
    var transAmt = record.getFieldValue(transAmtFldId);

    In that form’s record script field.

    Will an externally caused change to the field value fetched into “transAmt” will cause the record’s script to run? Are you actually tracking references, or tracking explicit field ID values in code? The examples I see always seem to show the latter, but that may be for simplicity.

    –Richard

    #48433

    In reply to: Unique value

    Lane Robinson
    Participant

    I also like the comfort of having a ‘unique value’ forced on a record field, but I can live without it with auto incrementing or the UUID option. Having dug into Tap Forms enough, I bet a person could write a Script that does this. Once I’m further along in converting my old database into a Tap Forms version, I’ll revisit this and will post my solution on the forum.

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