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,161 through 2,175 (of 3,095 total)
  • Author
    Search Results
  • #39638
    Sam Moffatt
    Participant

    I have recently been working on something like that to scan a bunch of items into boxes and similar. There are a couple of ways of handling it.

    I’m going to rephrase some of your questions:

    Can I pull up a box by scanning it’s barcode?

    This one is relatively straight forward application of the search functionality, that’s easy out of the box regardless of what platform you’re on. On the desktop you’ll need a barcode scanner to make that work but on iOS the built in barcode scanning functionality will make that work for you there.

    Can I scan barcodes of items as I place them into the box?

    The way I did this in January when I was doing a lot of box packing for moving was to create a second form called “Box Items” that is linked from my main “Box” form and then created child records. I was taking pictures of the item and adding some extra metadata in this case so I just used the built in Tap Forms barcode scanner to scan items and used voice to text to quick enter titles (worked enough times to save me having to type).

    Now if you invest in a barcode scanner, you can take it a little bit further and create a prompter loop to scan barcodes and automatically create new child records. You can also pivot and if you’re confident an item will only be in a single box, you can make it’s box barcode a property of the item. I have a prompter loop I use for bulk scanning shipments, I’ll post that on the Script Talk forum later.

    Can I checkout of a box?

    If you go with the Link to Form and enable show inverse relationship (or what ever that checkbox is called), then when you scan in your item in Tap Forms using the search feature it will show you the record and the “Link From Form” will show you the details of the box that it thinks it should be in. In Tap Forms on the desktop you can select this and change it to search for a new box which you should be able to do by barcode for your checkout box or just have a box named “checkout”. By changing the value of the Link from Form field parent will register it to a new box. The iOS version has a similar interaction here but I feel that it isn’t quite as smooth as the desktop more due to the limitations of iOS rather than Tap Forms (the desktop shows a popover which makes it much easier to interact with).

    If you go for the field based approach, you just need to update the field to where ever you put the item.

    In both cases you can script it to handle it easier. Scripting the Link to Form/Link from Form is a little more difficult because in the current production release of Tap Forms there is no search by text via the script interface. Brendan mentioned that he’s adding a form.getRecordsForSearchTerm() to the next beta which would make that easier because the JavaScript API for the link fields works with records. Until then, it’s a little easier to update a simple text field based on a search.

    I have a dedicated barcode scanner for the desktop, I bought a NETUM Bluetooth scanner that has both a USB cable for input and can pair via Bluetooth. I’m not sure I’d recommend it, it works fine in Bluetooth mode but when I plug in the USB cable it mangles the numbers some how (it’s like it’s pressing on the keypad numbers upside down). On the Mac I use Karabiner Elements whose mere existence seemed to make the scanner behave properly.

    Max Heart
    Participant

    Hi everyone,

    I am trying again to find help. The first round, including some good advise was here:

    Inventory barcode scanning – assign box/ placement


    Unfortunately, I did not manage to create a workflow as I am not familiar with scripting.

    Here’s my goal and setting:
    I want to create a home inventory which helps me finding my stuff quickly. I have two forms: one for boxes and one for the items. From the boxes form I created a one to many link as one box contains many items but one item can only be in one box at a time. Each box has a QR code, each item has a bar code.
    I managed to create my forms and the relationship and search is working. The barcode search will find items and boxes.

    Here comes the challenges:
    1) Batch entry of items using barcode
    Can I pull up a box by scanning its barcode and then start a batch scan barcodes of items as I place them in the box?
    2) Batch checkout of items
    Let’s say I pack for a trip and remove a lot of stuff from different boxes. I guess, in the boxes form I should create a box called “Checked Out”. Is it possible to first search for an item, have the box displayed where it is and then move this item to “Checked Out”?

    I use my iPhone for scanning but in case this workflow only works with a dedicated barcode scanner on the desktop version, I would be happy to buy one. I am just kind of lost and couldn’t find a tutorial.

    Thank you for your help, Max

    #39632
    JBW
    Participant

    Hey there. I’m trying to move from airtable to tap forms.

    I can (and have) downloaded the tables from airtable to csv files. I can import these csv files as forms into tap forms. However, I cannot seem to link certain fields to other forms during the import. After I’ve toyed around a bit, I think I understand why I couldn’t do that. But maybe I’m missing something.

    So I tried to build a script that would take an existing text field, and move it over to an already “linked to” form. But I’m not a script writer.

    I need some help.

    I have a form called “classes” with a field called “players” that has comma delimited names in it as text. I would like to have a script that goes to each “players” field, grab each name, and add them to the “linked to” field called “players-linked”.

    I have another form called “players” that has each individual as a record (first name, last name, etc.).

    I can code a little, but I don’t understand how to handle the loops, or selections in tap forms. I need to do this script to a handful of other fields as well. If I can get one to work, I feel confident I can modify it to make the others work. Any ideas?

    #39616
    Sam Moffatt
    Participant

    Try revenue_total.toFixed(2); as your last line and see if that gives you the desired effect.

    As a lateral answer, you can configure the script field with a particular format. If you reconfigure your script field to use a “Number” return type, you can then use the number formatting options in the field configuration to have it display the way you want.

    #39611
    Bernhard
    Participant

    @Sam: Sounds good – thanks for the advice!
    For the record, here is how it works:

    
    var customerRecordIds = [];
    
    // Callback function of the Prompter call.
    function chooseCustomerCallback() {
    	createInvoice(customerRecordIds[choosenTitle]);
    }
    
    // Do something with the record after the user choose one.
    function createInvoice(recordId) {
    	var customerRecord = form.getRecordWithId(recordId);	
    	...
    }
    
    // The entry function of the script
    function Erstelle_Rechnung() {	
    	var titleFieldId = 'fld-aa817f3bd885458883d3e25802fd4037';
     	var customersForm = document.getFormNamed('Kunden');
     	var customers = customersForm.getRecords();
    	var companyTitles = [];
    	
    	for (var index = 0, count = customers.length; index < count; index++) {
    		const title = customers[index].getFieldValue(titleFieldId);
    		companyTitles.push(title);
    		// Remember the Record ID of this customer record to be used later.
    		customerRecordIds[title] = customers[index].getId();
    	}
    
    	var choosenTitle;
    
    	let prompter = Prompter.new();
    	prompter.addParameter('Kunde', 'choosenTitle', 'popup', companyTitles)
    		.show('Message prompt', chooseCustomerCallback);
    
    	return null;
    }
    
    Erstelle_Rechnung();
    
    #39609
    Bernhard
    Participant

    Sounds good – thanks for the advice!
    For the record, here is how it works:

    
    var customerRecordIds = [];
    
    // Callback function of the Prompter call.
    function chooseCustomerCallback() {
    	createInvoice(customerRecordIds[choosenTitle]);
    }
    
    // Do something with the record after the user choose one.
    function createInvoice(recordId) {
    	var customerRecord = form.getRecordWithId(recordId);	
    	...
    }
    
    // The entry function of the script
    function Erstelle_Rechnung() {	
    	var titleFieldId = 'fld-aa817f3bd885458883d3e25802fd4037';
     	var customersForm = document.getFormNamed('Kunden');
     	var customers = customersForm.getRecords();
    	var companyTitles = [];
    	
    	for (var index = 0, count = customers.length; index < count; index++) {
    		const title = customers[index].getFieldValue(titleFieldId);
    		companyTitles.push(title);
    		// Remember the Record ID of this customer record to be used later.
    		customerRecordIds[title] = customers[index].getId();
    	}
    
    	var choosenTitle;
    
    	let prompter = Prompter.new();
    	prompter.addParameter('Kunde', 'choosenTitle', 'popup', companyTitles)
    		.show('Message prompt', chooseCustomerCallback);
    
    	return null;
    }
    
    Erstelle_Rechnung();
    
    #39608
    Barry Shevlin
    Participant

    I’m almost embarrassed to ask this given it’s probably such a basic question. However, I could well use the following script given as an example in the TF5 manual:

    var records = form.getRecords();
    var revenue_total = 0;

    for (var index = 0, count = records.length; index < count; index++){
    var theRec = records[index];
    var movie_revenue = theRec.getFieldValue(‘fld-987c9aac738a4f0fa1d18395902b3fc1’);
    if (movie_revenue) {
    revenue_total += movie_revenue;
    console.log(‘Revenue: ‘ + movie_revenue);
    }
    }

    revenue_total;

    My question is this: how do I limit the revenue_total return to 2 decimal places (currency)? I am getting this sort of thing: £63.9300000000001.

    Sorry if this time-wasting but I’m sure there’s a quick answer that would save me hours of fruitless futzing. Thanks.

    #39594
    Bernhard
    Participant

    Hi all,

    as Javascript/Typescript programmer I’m used to the comfort of IDE’s like Visual Studio Code.
    I would like to edit Tap Forms scripts in my preferred editing application. In the _Edit form script_ window I could imagine a button like _Edit in external editor_ which opens the script in a configured editor application and automatically syncs changes back from the editor to the Tap Forms window.

    What do you think?

    #39592
    Larry Stoter
    Participant

    Do functions like getMinOfField(date_id) work with date fields? I suspect not …

    I have a form with a number of records and a date field. The dates in the date field are not necessarily in order of entry. I want to find the earliest date in in the date field. The following script reurns O ….

    var date_id = 'fld-1482677011584a9da584a27e8835f5a4';
    var FirstDate = form.getMinOfField(date_id);
    Utils.alertWithMessage('FirstDate','First date is ' + FirstDate);

    Suggestions for finding the earliest date?

    #39570
    Sam Moffatt
    Participant

    Most of the web based Javascript tutorials will be correct for Apple’s JavaScriptCore that Tap Forms utilises. There are some special objects in browsers like console, window and document that aren’t relevant to JSC and there are some functions not in the ECMA standard that are commonly available in browsers.

    On that note, the w3school’s JS Reference page on arrays should give you a better introduction to arrays though you might find some items don’t quite work. Core elements of the language like arrays should be fine.

    You might want to check out something like Javascript The Good Bits or other books on getting started with Javascript as well to learn this unique and peculiar languages quirks.

    #39567
    Sam Moffatt
    Participant

    In the records list screen for a form that has calculations/scripts, if you pull down like you’re trying to scroll past the top and if you pull it/hold it long enough it should popup with a message at the top of the screen saying “recalculating” or similar.

    #39566
    Wonnie Bad
    Participant

    Hi Tonyt,

    It’s a general question. In reply #33263 Brendan says

    Pull to refresh on the records list screen is your friend :)

    I would like to make a script that gets my records with to-do date in the future and if the date is tomorrow it moves it to a to-do-tomorrow list.

    I searched for a pull-to-refresh sign on iphone Tapforms form record list, but couldn’t find it..

    Thanks for trying!

    #39563
    Victor Warner
    Participant

    Brendan,

    Thank you.

    Is there a place where this type of syntax is explained or summarised.

    At https://www.tapforms.com/help-mac/5.3/en/topic/scripts you mention https://tc39.github.io/ecma262/, but a search ‘length’ produces page after page of entries, none of which seem particularly helpful/digestible for a person who knows nothing about JavaScript.

    #39552
    Victor Warner
    Participant

    Brendon provided some sample JavaScript to enable me to use the first record from a linked form:

    if (passportRecords.length >0) {
    
    var firstPassportRecord = passportRecords[0];
    
    var passport_number_id = 'fld-9fe227057cdf44bfa62ad8a97cc6a62a';
    var nationality_id = 'fld-0039b290b2054881ac8f004c01903c6f';
    var country_id = 'fld-6e861fab76b9457bb625953cece54c96';
    var date_of_issue_id = 'fld-0154d8f9ce384e708502fdd775d7bfb1';
    var date_of_expiry_as_text_id = 'fld-b76a031084a94d7e8927ad347e10e24b';
    
    var number = firstPassportRecord.getFieldValue(passport_number_id);
    var nationality = firstPassportRecord.getFieldValue(nationality_id);
    var country = firstPassportRecord.getFieldValue(country_id);
    var IssueDate = firstPassportRecord.getFieldValue(date_of_issue_id);
    var ExpiryDate = firstPassportRecord.getFieldValue(date_of_expiry_as_text_id);
    
    result = "date of birth " + record.getFieldValue(date_of_birth_as_text_id) + ", residing at " + record.getFieldValue(address_full_id) + "\r\r" + "Identified by " + record.getFieldValue(gender_id) + " statement and production of current " + country + " passport, passport number " + number + ", expiring on " + ExpiryDate + ", " + nationality + " Citizen"
    
    }

    I now would like to know how to obtain the last record from the linked Form. I can see how if I wanted the second record or the third record.

    But The issue is that I do not know how many records there are in the linked Form. In some instances there will be only 1 in other 2, 3 or more.

    Is there a command to look for the last record alone or another way to find out the last record and use it?

    Any help would be gratefully received.

    #39545
    Brendan
    Keymaster

    Hello TJ,

    I moved this post to the Using Tap Forms forum because I think it’s better placed there. The Template Exchange is mostly for posting your templates that you want to share with others.

    Tap Forms does have an Auto-Complete function built-in to it. You just have to click on a checkmark button to turn it on for your Text fields. Then Tap Forms will keep track of the previously entered values for that field and will provide a popup menu of those values.

    Also, Tap Forms has Pick Lists, which are pre-defined lists of values that you can setup and then choose from as you enter data into your fields.

    For your calculations, you can definitely do that.

    However, you would probably need a couple of fields to store the subscription costs based on whether they’re annual fees or monthly fees. Because Tap Forms wouldn’t be able to detect if you typed in “$2/month” or “$24/year”. So having a couple of different fields would handle that for you. For example you would maybe have a Monthly Fee number field and an Annual Fee number field.

    Then you could have a couple of Calculation fields to do the calculation for you.

    For Monthly Fee the formula would be:

    Monthly Fee * 12

    And for the Annual Fee, the formula would obviously be:

    Yearly Fee / 12

    And Tap Forms can also do grand totals for you and display the results at the bottom of the records list view.

    With Saved Searches you can create sub-lists of your subscription records based on different years.

    Hope that answers your questions ok.

    Thanks!

    Brendan

Viewing 15 results - 2,161 through 2,175 (of 3,095 total)