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 2,952 total)
  • Author
    Search Results
  • #44383
    Sam Moffatt
    Participant

    There are some scripting solutions to copy a record to another form but in general the suggestion is to use saved searches to filter and limit records that are retrieved.

    Perhaps you can share a little more about your workflow, what you’re trying to achieve and how moving records between forms solves this for you?

    #44377
    Sam Moffatt
    Participant

    That’s an interesting approach, I didn’t think of a full export cycle, I was trying to get at it via scripting. That gets me thinking about leveraging something outside the ecosystem.

    I’d probably lean on CouchDB and use that to watch it’s change log and then each time a record with an image is added, process it in something I’m comfortable in (generally PHP) and then just have that rewrite the entry in CouchDB. If I needed it to be responsive, I’d probably set a smaller timeout and try to wait for a quiet period on the record (older than five minutes?) before triggering the update so as to not be too disruptive and create conflicts. It could be an overnight thing so that it minimises the risk of conflicts as well but that experience wise isn’t great. Now I’m riffing maybe even have a script trigger to extract the record, process the data and hand it back to Tap Forms then have TF handle updating the record so at least the users TF document is consistent and the writes are generally going in one direction.

    Fun problem to solve :)

    #44373
    Sam Moffatt
    Participant

    I don’t think there is a ready filter for the next X days, you can emulate it by doing two clauses in the search. That’s a little janky but for one off it’ll work.

    The other trick is to use a calculation or script field to calculate a value and then search based on that value but you need to refresh all of your records because calc/script fields are only evaluated when they’re modified.

    In your calculation editor, something like this:

    days(<double click on your date field to insert it here>, TODAY())
    

    Should do the trick. Again, caveat is you need to refresh all of your records to use the search (that’s the refresh button beneath the record list not to be confused with the refresh button beneath the record).

    #44358
    Brendan
    Keymaster

    It would be good to have some cover methods to let you write directly to the file system from JavaScript.

    #44356
    DrJJWMac
    Participant

    Thank you again.

    I am beginning to think that an easier alternative will be to export as CSV and then run a converter (AppleScript or other) to massage the CSV to raw.

    FWIW, my objective is to use TapForms as a front end GUI to a database of LaTeX-encoded problems. An example record output would appear as below.

    \begin{defproblem}{enthalpy-phasetransitionenthalpy-default}
    From the attached plot, what is the molar enthalpy $\Delta_{vap}\bar{H}$ to heat the room?

    \smallskip

    \putfig[0.1\textwidth]{fig-enthalpyplot}
    \end{defproblem}

    I can set fields for the topic (enthalpy), problem (phase transition enthalpy), set (button choices from A … example, default), LaTeX problem (From the attached plot …), has figure (yes/no), figure name (enthalpyplot), and relative figure size (0.1). A JavaScript field builds the final output from the data form. I intend to use this to administer sets of problems in a topic to track across exams, homework, and examples. I can build the exam or homework questions and then add examples (eventually with answers) to assure that students have seen what I will test against. The raw outputs for any cases are compiled into a final document using a LaTeX package called probsoln.

    In closing, I will use this thread once more to request a RAW/ASCII export option either directly or through JavaScript.


    JJW

    #44350
    Sam Moffatt
    Participant

    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.

    #44340
    Sam Moffatt
    Participant

    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.

    #44338
    Sam Moffatt
    Participant

    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.

    #44335
    DrJJWMac
    Participant

    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

    #44332
    Theo Theodosiou
    Participant

    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.

    #44329
    Daniel Leu
    Participant

    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

    #44327
    Theo Theodosiou
    Participant

    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.

    #44319

    In reply to: Weeks of work LOST

    Brendan
    Keymaster

    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

    #44318
    Brendan
    Keymaster

    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.

    #44312

    In reply to: Add to Calendar

    Jaime Moreno
    Participant

    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!

Viewing 15 results - 1,291 through 1,305 (of 2,952 total)