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,621 through 1,635 (of 2,952 total)
  • Author
    Search Results
  • #42329
    Sam Moffatt
    Participant

    I figured I’d have an attempt at getting this to work and I wrote a VBA script. I got it to work to parse out a URL encoded key/value string and replace stuff and I sort of got it to work based on a template. I say sort of because if I cold load the template in Word, click “Enable Macros”, it gives me a “Object doesn’t support this action” and if I click “End”, close it out then re-open the template (and “Enable Macros” again) from Finder it seems to work properly.

    It works to the point that it takes input from the clipboard (sort of) and then replaces the document. If you look at the raw file you can see that I wrap the placeholders with two underscores and this is mapped back to the keys in the query string pattern.

    Sample text to copy:

    FirstNamePlaceholder=Tap&LastNamePlaceholder=Forms&PrizePlaceholder=one+million+dollars&TransferAmount=$200&AddressPlaceholder=1%20Infinite%20Loop%0ACupertino%2C%20CA%2095014%0AUSA&SignatureName=Steve+Jobs&
    

    To create the string to copy from an array, something like this should work (borrowed from elsewhere):

    var queryString = Object.keys(params).map((key) => {
        return encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
    }).join('&');
    

    It’s janky but it is sort of functional.

    I’ve wanted a HTML type layout but printing that is oddly hard in the Apple ecosystem. There is printing support for WKWebView but apparently it’s private on the Mac and it looks like maybe it works on iOS. I found a QT based WebKit HTML to PDF library that might work on the Mac but I’m not sure if it’d pass App Store review because you’re embedding WebKit again. I found some code to create a PDF from a WKWebView using Swift that is a little newer but not sure if that’s functional. HTML layout wouldn’t replace a fully fledged multipage aware report generator that would let you do stuff like headers and footers but it might help provide some more basic use cases.

    Attachments:
    You must be logged in to view attached files.
    #42308
    Chris Ju
    Participant

    (first topic was marked as spam)

    Hi,

    i’m using the prompter dialog to enter text and date/time for a new cild record:

    let prompter = Prompter.new();
    prompter.addParameter(‘Note:’, ‘note’, ‘text’)
    .addParameter(‘DateTime:’, ‘datetime’, ‘date_time’)
    .show(‘Message prompt’, callbackFunction);

    The field “Note” is filled with the texted i entered in the dialog, but “DateTime” is still empty. What is wrong with my script?

    Is it possible to add days/weeks/years (choosing from picklist in the prompter dialog) to the current date and add the result in the DateTime field in the created record?

    Thanks
    Chris

    #42305
    Chris Ju
    Participant

    Hi,

    i’m using the prompter dialog to enter text and date/time for a new cild record:

    let prompter = Prompter.new();
    prompter.addParameter(‘Note:’, ‘note’, ‘text’)
    .addParameter(‘DateTime:’, ‘datetime’, ‘date_time’)
    .show(‘Message prompt’, callbackFunction);

    The field “Note” is filled with the texted i entered in the dialog, but “DateTime” is still empty. What is wrong with my script?

    Is it possible to add days/weeks/years (choosing from picklist in the prompter dialog) to the current date and add the result in the DateTime field in the created record?

    Thanks
    Chris

    #42302

    In reply to: Script stopped working

    Sam Moffatt
    Participant

    Ok, I finally got around writing this up, you can grab the script from my GitHub and there is also sample execution code as well. If you use my updated Script Manager you can pull down everything. The GitHub page has an example of a confirmation dialog done async and also a text input. You can use a similar approach of wrapping your method in an async block and it should execute neatly.

    Here’s a little broader of an example:

    async function comboExample() {
    	let confirmed = await promptConfirm('Are you sure?');
    	console.log(confirmed);
    
    	let details = await promptText('Enter Value', 'Location:');
    	console.log(details);
    
    	Utils.alertWithMessage("Sample messsage", "Message text");
    	console.log('Sample message');
    }
    
    comboExample();
    
    #42298
    Sam Moffatt
    Participant

    A while back I posted a Script Manager form and here I am with an updated version. This version now adds an extra form for “Repository” which adds the ability to automatically download scripts and update them. To use it, import the archive attached to this post, go to the newly created “Repository” form and use the “Update Scripts” form script to download all of the scripts listed in my GitHub repo. It provides a level of automatic versioning so that if something goes wrong you can easily rollback to a previous version of the script.

    I’ve got a video on YouTube showing how to import it and some of the features of it. I have a plan to do some more to cover some of the scripts.

    Attachments:
    You must be logged in to view attached files.
    #42297
    Brendan
    Keymaster

    I don’t know how you would open a docx XML file within JavaScript, then update it and save it back. I don’t think the JavaScriptCore framework I use in Tap Forms would allow that. So Sam’s solution of copy and paste might work. Tap Forms can set values on the clipboard from a Script.

    But if you don’t need a Word file for this task, you could use Tap Forms with a custom layout and a static Text object on the layout. Within the text object, insert the field names with square brackets around the names and when you print, Tap Forms will substitute the values.

    For example:

    Dear [First Name] [Last Name],
    
       We have come to the realization that you need to pay $[Amount Due] by [Due Date] or you will be charged an additional [Penalty Percent]% interest on your loan.
    
    Sincerely,
    
    The Lending Company

    You can even stylize the text within the Text object.

    To add a Text object, click the Layout button, then click the A button above the layout inspector panel. Then click on your layout and type in your form. You can even paste from Word into there. But I would probably paste as plain text to remove any formatting and then use Tap Forms to format. Word might add all kinds of crap into the formatting that you don’t want.

    If you need more than one page though, you can add another layout and then chain the layouts together.

    Thanks!

    Brendan

    #42296
    Chris Ju
    Participant

    My idea was to replace text/field (e.g. “nName”, “aAddress”, …) in the docx (=xml) file with the content from Tap Forms fields (name, address, …) using javascript. I know, that it is possible with apple script in other apps…

    #42295
    Sam Moffatt
    Participant

    I thought I’d replied to this but I guess I didn’t hit submit or something.

    My immediate thought would be to use the clipboard to shuttle data around, encode it in Tap Forms and then use VBA to grab the clipboard and splice it into the template, if you put the file in the script directory for Tap Forms then you might be able to attach it via a script as well though it’s a little janky all told.

    Some other folk have had success with AppleScript and also Keyboard Maestro that might be able to automate things.

    I’m not sure any of it is a good solution for automating Word but that might help you along.

    Chris Ju
    Participant

    Hello,

    has anyone tried to fill a fields in a Word file (template in Finder) with data from form fields using java script and adding this Word file to a record as file attachment?

    Is that even possible?

    Thanks.

    Chris

    #42276
    Sam Moffatt
    Participant

    Finally got around to recording the video for the barcode scanner. It walks through using Tap Forms on iPadOS to create a new form, create a new script that creates records for that form and then jumps over to Shortcuts to do the barcode scanning piece. From there you can use that shortcut on your home screen to quickly scan a barcode and import it into a Tap Forms record.

    #42264
    Brendan
    Keymaster

    There’s an example of fetching data for movies given an ISBN barcode number. This can be combined with barcode scanning so when you scan the ISBN number on the back of a movie disc, when Tap Forms saves the values, the script will be triggered and the movie details will be filled in.

    https://www.tapforms.com/help-mac/5.3/en/topic/scripts

    Look for Fetch movie data from web service to see the example.

    #42263
    Sam Moffatt
    Participant

    I don’t think there’s a post for the barcoding scripting stuff, I’ve been meaning to document it. I have one other thing on prompting I want to do and then something on my Siri Shortcuts to TF script work for shipment importing (scan tracking number, update existing record if match found or create new record for later handling).

    #42260
    Dustin Betterly
    Participant

    @sammoffatt, appreciate the comments input, and I apologize for any stupid questions I may ask. To start, I’m no programmer, so is there any where on this forum that documents the scripting process for barcodes/QRcodes?

    #42253
    Sam Moffatt
    Participant

    On iOS/iPadOS, there are a few places where a built in barcode scanner: you can use a barcode scanner to import into text fields and there is also a barcode scanner in the search boxes. Via the scripting interface, I’ve also leveraged iOS’ built in barcode scanner to quickly do a scan from shortcuts on the home screen and launch a script to do a search/import flow in the app.

    The multicolumn list view is the closest to a spreadsheet view but you can always export the data out to CSV for use in a dedicated spreadsheeting tool. The desktop has custom layouts but it is a little limited when it comes to making reports with nested data.

    #42203
    Sam Moffatt
    Participant

    Good to hear you got it sorted, recalculation is a little magical but should happen when the field changes. If you suspect something funky, you can always hit the refresh button below the record that will trigger a recalc of all calc fields in the record (script fields too). Sometimes useful for flushing out the gremlins.

    The script field is a front end to Apple’s JavaScript Core which is itself an implementation of ECMAScript 2015 (or later?). Script fields behave like calculation fields but execute Javascript and there is also a form script which can be executed on demand.

    Apple’s JavaScript Core doesn’t have stuff outside the ECMAScript standard that you’d expect to see commonly from web browsers but the core standard JavaScript is accessible. To interact with Tap Forms is a specific JavaScript API that gives you access to some of the internals of Tap Forms. I have some examples on my GitHub of JavaScript and there is also the Script Talk forum focused on JavaScript. If you’re a beginner, T. L. Ford’s got a Tap Forms Javascript Scripting 101 tutorial too.

Viewing 15 results - 1,621 through 1,635 (of 2,952 total)