There isn’t a way to write a file directly, if I was to put it straight to a file I would send it to a web service and use that to dump it to disk for me. You can use Utils.postContentToUrlWithContentType() or Utils.postJsonToUrl() to call out to a web service. Probably for your use case postContentToUrlWithContentType with a simple text content would suffice. They’re pretty simple API’s with details on the Javascript page.
Something like this should work:
let entries = [];
for (let record of form.getRecords()) {
entries.append(record.getFieldValue('fld-yourfieldid'));
}
Utils.postContentToUrlWithContentType(entries.join("\n"), "http://localhost/tapforms-bridge.php", "text/plain");
Then tapforms-bridge.php could look like this:
<?php
file_put_contents("/tmp/file.txt", file_get_contents("php://input"));
As a simple example of getting data out, it’s not the greatest solution but it should do the trick. You’d need to get the built in Apache and PHP set up on your Mac but there are plenty of guides out there for that.
Would you be able to share a screen shot of what you’re seeing because I think I’m a little lost.
One thing to note is that the view settings for link to form fields can be different to the normal view settings for that form though I’m not 100% sure that’s what you’re seeing so if you haven’t already, hit view settings on the link to form list and make sure that field list has what you expect in it. It should be hidden on the record detail view when you get there, regardless of how you get to that view but the multicolumn list view screens can have different fields than the default form would have. The only other thing I can think of is that the hidden field is at the top of your list and is some how being rendered by the single column list view settings but I couldn’t replicate that on my own iPad for testing.
Some folk have used text fields and scripts to build some pretty interesting report style interfaces, the Markdown stuff allows for some of that but it’s a limited form of Markdown to work with the printing system. It’s not the greatest system but it does provide a mechanism for building some sort of a structured report at least.
The CSV export will likely wrap things in quotes for compatibility reasons, I don’t believe there is a way I’ve seen to turn it off.
You could easily create a form script that generates the output via console.log that you could easily grab out of the display, something like:
for (let record of form.getRecords()) {
console.log(record.getFieldValue('fld-yourfieldid'));
}
Would do the trick to dump out all of the records to the console for you. Replace the fld-yourfieldid with the field ID you care about, you can get the field ID by double clicking on the field you want in the script editor or from underneath the field description in the field editor.
I am creating a database with text fields. I want to export the data records as the equivalent to raw, ASCII text. I do not want the quotation marks around the text and I want the “\r” (carriage return) character to expand properly.
How can I accomplish this?
I am conversant enough in the JavaScript to use that method if needed.
—
JJW
Thanks guys. Yes, I have tried setting the field option to hidden for these fields in customize form, and also in the view setting for the multi-column layout. In both cases the fields are hidden when I select the form itself, but when it is displayed as a linked form the fields show in the list.
So as an example if I select the Albums form for say Classical, the fields are hidden in both the list view and multi-column display view, whichever I choose. However, when I select an artist and the form links the joined rows from the associated albums the columns in the album list are not hidden.
It’s a shame because I actually have a third form in each classification called Tracks which is linked to Albums. So I can select an artist, then from the linked album list I can select a specific album and end with a track list. Sweet. It is just a shame that the albums and tracks show the hidden key fields which I used to link them.
I should add that I realise that this last issue is off topic and not really a script issue but I guess this is an area when it would be nice to be able to have an associated script to allow dynamic tailoring of views but I realise this is a big ask.
Sorry, I don’t have a trick up my sleeve. The idea with a reference form might be the best workaround. I would write a script function to fetch the formID. This way, if @brendan adds something like form.catogory, you just can update that function and everything else in your code continuous to work. But here I’m just stating the obvious ;-)
I have also noticed that hidden fields are still visible in the display when forms are referenced via a ‘Link to Form’ join. This is already messy as I currently have hidden key fields that clutter the display so I would like to keep these to a minimum.
On the desktop you can select which fields are shown in the table by clicking on the icon at the top-left of the table. I’d assume that there is a similar setting on mobile.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Thanks Daniel. Please excuse me if this reply appears more than once but my last attempt seems to have disappeared into the ether.
I have indeed thought about a custom field but this would be at record level which would be overkill I think. Also I don’t believe it will help when creating records. I agree that a forms.category approach would be a good option.
The whole story is that I am writing a script that calls a REST service I have written on a windows machine to ask for updates. (I no longer have my Macbook). When the script receives notification of a new record it will know to which Category and Form the record needs to be written. So I need a way of saying; get me the Id of form ‘Artists’ in category ‘Classical’. I think I will need to create a reference form in the Uncategorized section (which I am using to hold common code) and create a field for each of the Forms that I need to reference which can hold its internal unique Id. I will then use this to target the form when I add a record.
I was hoping to avoid hardcoding these and just feel that being able to reference a form in an abstract manner would be more elegant.
I have also noticed that hidden fields are still visible in the display when forms are referenced via a ‘Link to Form’ join. This is already messy as I currently have hidden key fields that clutter the display so I would like to keep these to a minimum.
However, your comments are appreciated and confirm my understanding. I was hoping I had missed a trick.
Hello Teo,
Were you unlinking a record from an inverse relationship on a Link From Form field? If so, I recently fixed a bug that could cause more than just the selected linked record to be unlinked.
I haven’t yet published the fix for this issue though. If you’d like to test a beta version with the fix, I’d be happy to set you up. Just email me at support@tapforms.com. The records should still be there, just not linked for that record anymore. I’m just guessing that this might be what happened based on your description.
Sorry for this issue.
Thanks,
Brendan
Tap Forms uses the system controls for checkmarks and script buttons. And macOS decides how those look. But it is possible to override that and draw these things myself at some point.
This is the script:
function AddCalendar() {
var event_info = {“calendar_name” : “Reminders”,
“title” : “Test 1”,
“location” : “Location 1”,
“notes” : “Notes 1”,
“all_day” : true};
var start_date = new Date();
var end_date = new Date();
end_date.setDate(end_date.getDate() + 1);
console.log(start_date);
console.log(end_date);
console.log(event_info);
var identifier = Utils.addToCalendar(event_info, start_date, end_date);
console.log(identifier);
}
AddCalendar();
And this is the console.log output:
5/7/21, 4:15:15 PM / Test Calendar / TestScript
Fri May 07 2021 16:15:15 GMT-0400 (EDT)
Sat May 08 2021 16:15:15 GMT-0400 (EDT)
[object Object]
undefined
Thanks!
I found an old entry asking this question, but did not find an answer for it. The script button does not take the stroke color and fill color specified for it. Similar situation with Check Mark field. In contrast, Text and Number fields do. See attached figure.
Can this be fixed sometime?
Thanks.
Attachments:
You must be
logged in to view attached files.
Reading the description for Categories, it looks to me that this is just a feature to better visualize forms and it is not a hierarchical component. Specially for your case, it would be helpful to have something like form.category to check which category the form belongs to. There is currently no API to support categories. Maybe something @brendan might in the future.
Instead of using the formId, you might just use a custom field where you store the category. If it is just for a few forms, that’s not a lot of work and you can hide the field in order not the clutter the UI.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Can you post your script?
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
I have followed the instructions for using Utils.addToCalendar, but something is not working.
The console output for the line console.log(event_info) is “undefined”.
I tried using a script field and a form script, with the same outcome.
I am running MacOS 11.3.1 , in case it matters.
Is this function still available? What may I be doing wrong?
Thanks in advance for any pointers.
I have a requirement for which I plan to write a form level script. It is my first Tap Forms script although I have used Javascript extensively in the past.
My project requires that the script process multiple records from different forms within a document.
However, I have encountered a problem which I cannot see a simple solution to.
To explain; I have created a document that contains three categories. Within each category I have created forms where the name is the same in each category. I then have a form which I have created to hold the script that I can run once to process content in each of the forms for each category.
An example the Hierarchy would be:
Document:–Music
Category:—-Classical
Form:———-Artists
Form:———-Titles
Category:—-Classical
Form:———-Artists
Form:———-Titles
Category:—-Uncategorized
Form:———-Common script container.
I have written a simple ‘hello world’ form level script that I have placed in the ‘Common script container’. This script iterates over each form in the document and displays the form name with a list of its fields.
My problem is that I can’t find a way of differentiating the category when I list off the form names. I realise that I could create my own Category field but it seems that there should be a way of retrieving the category for the form via a function call but I just can’t seem to find anything in the documentation I have seen. I guess I could hard code the form Id to reference existing forms but how can I create a form in a specific Category using the ‘create New Form Named’ function.
Am I missing something?