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,291 through 1,305 (of 3,052 total)
  • Author
    Search Results
  • #45131
    Martin Kendall
    Participant

    Thank you for replying.

    The saved search was set up months ago. The record was added using a script since then, and the phone has been rebooted (over the weeks) since it was added, but it still doesn’t appear.

    I should say I am using Tapforms on my iPhone and iPad and even when the record is synced (using iCloud) it doesn’t appear on either device.

    Hope you can help,

    Martin

    #45127
    Martin Kendall
    Participant

    Hi,

    I’m setting a star rating when I add a new record using a script.

    When I do this the field value shows the correct number of stars in Tapforms – however if I create a search and query on, eg rating is 4, then the programmatically set four star records do not appear.

    Any records entered manually do appear and if I change the rating of my scripted 4 stars, to another rating then change them back to four, they do filter correctly.

    It just seems when they are set programmatically they don’t filter correctly.

    I am using record.setFieldValue() to set the rating.

    Can anyone tell me how I should be setting the rating so that the query works?

    Thanks

    Martin

    #45123
    Daniel Leu
    Participant

    Another option is to use a tapformz url:

    Utils.openUrl('tapformz://script/db-xxxx/frm-xxxx/ScriptName?option1=A&option2=B')

    This way you can directly call the script with the given parameters.

    Cheers, Daniel

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

    #45119
    Daniel Leu
    Participant

    The script you are calling should just define a function or several functions. So you don’t call the function at the end of the script that you usually would in a form or field script. Once the runScriptNamed() was executed, you would call the function in question with the given parameters.

    Cheers, Daniel

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

    #45118
    Konrad Schoettl
    Participant

    I have defined a form script that is called via ‘runScriptNamed()’ twice from different field scripts. This is basically working. An example: I have a form for all persons (authors, translators, actors, …). Within this form, I have fields for the date of birth and death. As sometimes only the year is known, in both cases I have defined separate fields for day / month / year. As for the month, there is a picklist with options ‘january, february, …). Now there is a script field which stores the person‘s name along with the dates of birth and death, for example ‘Wells, H. G. (21.09.1866 – 13.08.1946)’. To get this, a form script converts the month (september) to a numeric like text (09). This is done for birth and death.
    Now the problem: It seems there is no way to call the form script (‘runScriptNamed’) with parameters?
    I found a solution by using global variables, which works, but perhaps there is another (perhaps better) solution?

    Thanks for any ideas or hints!
    Konrad

    #45107
    Sam Moffatt
    Participant

    If you’ve not seen it, there is the concept of database normalisation which is the process of thinking about your fields and structuring the database. I will say that you might for various reasons want to replicate fields and the cool thing is that calc and script fields can help you copy data without having to manually maintain them.

    Good luck mapping it all out :)

    #45040
    Sam Moffatt
    Participant

    I think it’s more up to personal preference. If you want to add notes per variety that you plant or extra metadata specific to that day and variety, then you might want to use a record per day per variety. You could do a record per day and then use the link to select which varieties you planted that day. If you don’t track any other metadata with your planting then a single record per day might work (maybe a free form notes field).

    If you did per day per variety then you want to do a 1:M relationship and enable “show inverse relationship” checkbox on the Link to Form field then it will create a Link From Form field. On the Link From Form field, there should be four buttons: the first is an add button (it will create a new record and take you to the form), second is an unlink button, third takes you to the linked record and the fourth lets you select a new record. If you click the first button to add a new record, you can populate it from that screen and then jump back to the previous record with the back button that should appear at the top of the record next to the default layout selector. When you jump back it should have that linked already.

    If you wanted to do one per day then I’d do a M:M relationship it’s a similar process though you get a table view on both sides when you enable the “show inverse relationship”. It’s a little easier to do data entry with the tables for new records because you can do that inline or you can create a record and go directly to it (second option under table) to fill it in.

    In general you don’t need a primary key in the traditional database sense mostly because internally Tap Forms has unique identifiers, you only really need it for your own purposes. You can use calc or script fields to help you compact multiple fields into a single field to make it easier to pick out of the record selector.

    One other random thought is that if you only have a name for the variety and no other metadata, you might want to look either using autocomplete for it or at a pick list for it. Autocomplete does what it says on the tin and pick lists can be configured to refer to a particular field so you can get a sort of autocomplete that way. Pick lists have slightly more UI options and you can also do stuff like record highlighting with them.

    If you can take a short video and upload it to YT then you can link to it. If it’s quick enough and a small enough window area then it’ll fit into the file upload limit for the site. You might have found a bug in the system which would be a cool win as well :)

    #45017
    Sam Moffatt
    Participant

    By default the export defaults to exporting all records in a form but if you have a saved search you can use that to limit the scope. A method would be to create a check mark field that flags a record for export and then a saved search on that field. Then with that saved search selected, you can use File > Export > Records to get a CSV/XLSX with just those records (or a single one).

    You could write a form script to put data onto the pasteboard in what format you want. A little more effort but more flexible. If you have a web service, you can send the data to a web service via POST request. If you ran a local server, you could use that to write locally.

    #45012
    Sam Moffatt
    Participant

    Great to hear you got it to work and that the Script Manager stuff was helpful for you as well :)

    #45007
    Tom Kerswill
    Participant

    Hi

    I’m programmatically creating fields using:

    form.addNewFieldNamedWithType(key,fieldType)

    The documentation for that function in the scripting API gives the following field types:

    [text, number, calc, location, photo]

    I’d like to add a boolean / checkmark / yes-no field.

    Is this possible using a script?

    Tom

    #45006
    Tom Kerswill
    Participant

    Thanks so much for the help. I ended up writing something based on your great Script Manager, Sam, and then building out something to automatically add the fields (if they’re not already there).

    It works really well. Hooking into the existing CSV / Json import would be lovely; but doing it with a script isn’t too bad in the end.

    Here’s the snippet:

    		let targetRecord = 	getRecordFromFormWithKey(form.name,indexKeyId, rowId);
    		if (!targetRecord) {
    			console.log("Adding new record...");
    			targetRecord = form.addNewRecord();
    		}
    		console.log("Record: " + targetRecord.getId());
    		for (const [key, value] of Object.entries(row)) {  			
    let keyField = form.getFieldNamed(key);
    			if (!keyField) {				
    				console.log("Adding field: " + key + "Type: " + typeof(value));
    				if (typeof(value) == "number") {
    				fieldType = "number";
    				}
    				else {
    				fieldType = "text"
    				}
    				keyField = form.addNewFieldNamedWithType(key,fieldType);
    				form.saveAllChanges();
    			}
    			keyId = keyField.getId();
      			console.log("Key: " + key + " keyId: " + keyId + " Value: " + value);
      			targetRecord.setFieldValue(keyId, value);
    		}
    

    Tom

    #44967
    Brendan
    Keymaster

    And with setting the Script Folder on the Preferences screen, you can put your data in there and then use var data = Utils.getTextFromUrl(url); command to read in the file. Then parse it. The split() function could be used to split the lines into an array of lines. Then for each line, use split again to split by the column delimiter. But it really depends on how your data is structured. If you have delimiters within your content and quoted content, then that would be much more difficult to deal with. I should add a JavaScript API for parsing delimited content into two dimensional arrays of data, basically giving you access to the code I already use for parsing CSV files.

    #44938
    Daniel Leu
    Participant

    I don’t see an API for that. In one of my applications, I use the clipboard to import data into TF. It took a bit of time to get the data parsing right, but now it works well.

    If your data is already in CSV format, the parsing should be easy. I don’t think that such a script is that difficult since you already know where the data should go. You then call the script with tapformz://script/[document ID]/[form ID]/[form script name]?key1=value1&key2=value2...

    Cheers, Daniel

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

    #44934
    Tom Kerswill
    Participant

    Hi

    Is it possible to import data programatically? Ideally by using an existing import preset?

    I’d like to have something like Hazel or Keyboard Maestro trigger this when data in a file changes, so that I can reimport it into Tap Forms.

    I suspect I could probably do a form script that might do this; but ideally it would be able to trigger Tap Forms’ existing import system, as it can then do things like automatically setting links to other forms, etc., whereas I suspect this would be quite complex to do if building an import script from scratch.

    Thanks in advance,

    Tom

    #44915
    Sam Moffatt
    Participant

    You can use a script to get the children of one Link to Form field of JOIN type and then add them to another Link to Form field. In terms of script, a form script like this should do the trick:

    record.getFieldValue('fld-joinfieldid').forEach(rec => record.addRecordToField(rec, 'fld-1tomanyfieldid'));
    

    You could expand it to run on all of the records in your form but this will do just the currently selected record. I haven’t tested it but it should work.

Viewing 15 results - 1,291 through 1,305 (of 3,052 total)