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 - 2,461 through 2,475 (of 2,950 total)
  • Author
    Search Results
  • Sam Moffatt
    Participant

    I have a form called “Order” where I store stuff I order online. It has a child record called “Shipments” which store shipments. I often want to quickly add a new shipping record and use this as a form script with the prompter to add in a new shipment record with the tracking ID and carrier set. It also will set the shipping date based on the order record if it’s already set or default it to the current date.

    This uses the prompter for user interaction (including leveraging a pick list) and addNewRecordToField for adding a new record to a Link to Form field. It also demonstrates using setFieldValues to bulk set values and also uses JSON.stringify to dump out debugging information with console.log. Here’s a screenshot of the prompter:

    Prompter UI

    Field names are at the top, replace with ID’s matching your fields.

    // Order: Shipment Field ID
    var shipments_id = 'fld-db2fcdb4d79c466ea09671c47d2ae645';
    
    // Order: Ship Date 
    var ship_date_id = 'fld-6ab700ccc11d418fbd27d8899d00c7a9';
    var ship_date = record.getFieldValue(ship_date_id);
    
    // Shipments: Record Field ID's
    var tracking_number_id = 'fld-c487390743c947969cbe661cff596855';
    var carrier_id = 'fld-0950c430cb0c41f79c51d43a544b366b';
    var shipping_date_id = 'fld-1aa32f17e059424fb4e24bf894b34fdf';
    
    var callbackFunction = function() {
    	if (tracking_number && carrier)
    	{
    		var data = {
    			[tracking_number_id]: tracking_number,
    			[carrier_id]: carrier,
    		};
    		
    		if (ship_date)
    		{
    			data[shipping_date_id] = ship_date;
    		}
    		else
    		{
    			data[shipping_date_id] = new Date();
    		}
    		
    		console.log(JSON.stringify(data));
    		
    		var shipmentRecord = record.addNewRecordToField(shipments_id);
    		shipmentRecord.setFieldValues(data);
    		document.saveAllChanges();		
    	}
    };
    
    let prompter = Prompter.new();
    prompter.addParameter('Tracking Number', 'tracking_number', 'text')
    	.addParameter('Carrier', 'carrier', 'picklist', 'Carrier - Shipments')
    	.show('Message prompt', callbackFunction);
    
    Attachments:
    You must be logged in to view attached files.
    #35985
    Brendan
    Keymaster

    Hey Everyone,

    It was suggested to me that it would be a good idea to have a separate Scripting forum on my website.

    Well, here it is.

    This is the place to be if you want to post useful scripts to make Tap Forms do things you never thought possible.

    If you’re unfamiliar with scripting in Tap Forms, please see the Scripting topics in the online user manual here:

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

    and the Tap Forms specific JavaScript API docs are here. These are the functions you can call within a Tap Forms script that do things specific to Tap Forms, such as fetching a set of records, reading field values, setting field values, and updating the database.

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

    It’ll be great to see what kinds of scripts you can come up with to make Tap Forms more powerful than ever.

    Thanks!

    Brendan

    #35983

    Forum: Script Talk

    The place to be if you want to talk about Scripting in Tap Forms 5.
    #35982

    In reply to: Scripting Tutorials?

    Brendan
    Keymaster

    Ya, I could add a Scripting Forum. Good idea.

    And here it is:

    Script Talk

    #35981

    In reply to: Scripting Tutorials?

    Sam Moffatt
    Participant

    Would it make sense to have a forum section for sharing interesting scripts?

    #35980

    In reply to: Autopopulate with Data

    Brendan
    Keymaster

    Hi David,

    Are you using the Mac version?

    You could use the Fill Down command on the Multi-Column List View to reset the checkmark buttons for every record in your form so it’s ready for next time.

    Or, a simple Form Script could easily do that. You’d have to loop through the records setting the value of the checkmark field in the records to 0. Then save the form.

    Then whenever you’re done packing, just run the script and all the checkmark fields will be turned off.

    Thanks!

    Brendan

    #35974

    In reply to: Watched TV Shows

    Brendan
    Keymaster

    Hi Yvette,

    There’s a Run Script button on the Scripts tab for Mac. Click the Scripts tab, then select Import from imdb and then press the Run button. It looks like a black triangle. Like a play button on a video or an MP3 player.

    On iOS, view the list of records in the form, then tap the action menu button, then tap on the Run Script command.

    Thanks!

    Brendan

    #35971

    In reply to: Watched TV Shows

    Yvette M
    Participant

    Hi, I figured out where to put the API key. Now, how do you make the script run? When I go to scripts/ show console log/ it stays blank

    #35963

    In reply to: Watched TV Shows

    Ryan M
    Participant

    Hey Andrew – Do you see any errors or anything when clicking on the menu Scripts > Show Console Log? Keep that window open when running the script.

    #35960

    In reply to: Watched TV Shows

    Andrew Mead
    Participant

    Hi Ryan,

    Thanks for your response. Yes the clicking away from the form did resolve the issue of the script not appearing to run.

    I have found one other oddity though if you wouldn’t mind checking it out. Again using the V series The 100 via https://www.imdb.com/title/tt2661044/ if I run it now it does not pick up any new episodes since the first time the script was run.

    In the case of the The 100 there are at least 9 new episodes list on imdb that the script is not picking up and adding to the table.

    I have tried deleting the table and re running the script but I get the same result. In case you want to try he same I have added a screenshot showing what my most recent episodes are

    Many Thanks for your help
    Andrew

    Attachments:
    You must be logged in to view attached files.
    #35934

    In reply to: Watched TV Shows

    Ryan M
    Participant

    Hey Andrew,

    I just tried the script again in my own form and it worked fine. Do you see any errors or anything when clicking on the menu Scripts > Show Console Log? Keep that window open when running the script.

    One thing I’ve noticed is that the TV show won’t automatically appear. You have to click out to another form and come back and it’ll be there.

    – Ryan

    #35915
    Andrew Mead
    Participant

    Please ignore last post I realised I had to run the script by opening in the script editor first. I I run from he front screen it doesn’t work

    #35914
    Andrew Mead
    Participant

    Hi Brendan,

    Sorry if this is the wrong place to put this, but I am using the Watched TV Shows Template, which is exactly the thing I am looking for it’s just that the script doesn’t do anything, at least that is visible to me.

    I have generated my api key and have pasted that in the script in TF.
    Now when I run the script it asks for a IMDB URL which I paste in (example for The 100 would be https://www.imdb.com/title/tt2661044/ but then the script does not seem to do anything after that.

    Is there something I am missing.? The script console shows no messaged either. Any help would be appreciated.

    Thanks
    Andrew

    #35913
    Brendan
    Keymaster

    There’s no function to trigger the printing system from a Script.

    But you can press command-] to jump to the last record in a form, then command-p to print it.

    #35911
    tmc Company
    Participant

    Anyway thank you very much
    I solved it by synchronizing the database with the mac and print from there

    Is it possible to make a Script to print the last record from the MAC automatically with a button?

    Thank you !!!

    Excuse my English

Viewing 15 results - 2,461 through 2,475 (of 2,950 total)