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,141 through 1,155 (of 2,989 total)
  • Author
    Search Results
  • #45778

    In reply to: Pick Lists

    Brendan
    Keymaster

    Hi Yvette,

    Tap Forms doesn’t have the option to show or hide a field based on some condition. At least not on a per-record basis. A field script could hide or show another field, but it would show or hide for every record, so not very useful in this scenario.

    Your best bet is to just have the Other option and then another field below it that asks for the Other Location.

    #45754

    In reply to: Help with script

    Sam Moffatt
    Participant

    Purchase date to price to person doesn’t quite make sense to me but purchase date to person with price aggregated makes more sense, is that what you mean?

    You have two options that you can do, one is to start building a composite key with each of the fields you want as commas, that gives you a flat list but if it’s in CSV outputting it looks somewhat transparent. The other is to continue to add another array but that means a bunch of work to validate it as we’ve got (basically the process we did to add marketplace).

    I’ll do the first one because it lets you store an arbitrary number of roll ups at the cost of making it a little harder to extract later. Since you’re not using the roll up form and just the CSV this should be ok for you:

    Adding extra fields should be a matter of creating the variable and adding them to the rollupKey line. This should work though I’ve not tested it:

    function Aggregate_By_Date() {
    	// set our date format, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
    	// remove "day" from it and you'll roll up by month for example.
    	var dateFormat = { "day": "2-digit", "month": "2-digit", "year": "2-digit"};
    	
    	// this is where we're going to store the rollups per day.
    	var rollups = {};
    	
    	// iterate to all of the records in the form
    	for (var rec of form.getRecords()) {
    		var marketplace = rec.getFieldValue('fld-c163aba17ae64c4d93b5a53819a139dc');
    		var person = rec.getFieldValue('fld-personid');
    		var purchase_date = rec.getFieldValue('fld-ccbd9a8f51d34246bebfb31aa4e397dd');
    		var price = parseFloat(rec.getFieldValue('fld-08129d71ab0f4fa4a2749456281fca07'));
    
    		// Skip entries that don't have a price or date set.
    		if (!price || !purchase_date) {
    			continue;
    		}
    		
    		// format the date for use in the rollup.
    		var formattedDate = purchase_date.toLocaleDateString("en-AU", dateFormat);
    
    		var rollupKey = [formattedDate, marketplace, person].join(", ");
    
    		// Rollup to this key, add to the existing value or set it if not set.
    		if (!rollups[rollupKey]) {
    			rollups[rollupKey] = price;
    		} else {
    			rollups[rollupKey] += price;
    		}
    	}
    	
    	// log to console the aggregated values.
    	for (var rollupKey in rollups) {
    		console.log(rollupKey + ",$" + rollups[rollupKey]);
    	}
    }
    
    Aggregate_By_Date();
    
    #45753

    In reply to: Help with script

    Guillermo q
    Participant

    Hey there. Me again. SOrry to bother you. I’ve been using this script since you wrote it.

    I would like to add some data to the rollups, in order to manipulate the data in excel and make charts.

    I would like to add 2 more variables to the rollups, so it would be like this:

    Purchase date – price – person.

    I Have declared the variable person, but i am lost with the rollups. Any help?

    Thank you very much indeed =)

    #45751
    Sam Moffatt
    Participant

    I don’t think out of the box there is anything that quite does this in Tap Forms. The built in barcode scanner feature works on searching for records so I don’t think that’s a good fit for your use case and there isn’t a scripting/prompter interface to handle this.

    For me personally how I work around this is that I have a hand held USB/Bluetooth barcode scanner. That acts like a keyboard except it scans barcodes to “type” the text. I then use form script with a prompter to give me a text box and can scan barcodes to search then popup the answer.

    #45748

    In reply to: SMS sending

    Sam Moffatt
    Participant

    Awesome to hear you got a flow that worked for you! For something like 20 SMS that’s probably the best balance of automation and cost. Also great to hear the videos were helpful to you as well.

    @Brendan the API uses a POST so it’d be a Utils.postContentToUrlWithHeaders perhaps (content type is a header so no need to map that). Though maybe a more generic sendHttpRequest(method, url, headers, body) might make more sense? If it returned an object with the headers and body then it’d be easier to handle in Javascript as well. That would mean I could also do DELETE or PUT requests too.

    #45745
    Shane Kimrey
    Participant

    I need some help, I want to make an inventory where I scan a barcode search for the item and return a separate field result in my form. So I have a table of items that has a bar code. I scan the barcode and search for the record. Then in return a field showing a number listed.

    #45743

    In reply to: SMS sending

    Hi Sam & Brendan, thanks for your feedbacks but … I need to send about 20 SMS a month, and I’m a real good newbie in scripting, API, aso … (But, great thanks to Sam for his videos, I’ve transferred values to a child form successfully this morning, so happy !)
    So without a simple way to do that SMS stuff, gonna stay with this good ol’ copy-paste !
    Have a nice day

    #45738

    In reply to: SMS sending

    Sam Moffatt
    Participant

    You could use a form script to send an SMS using a web API gateway like Twilio. Twilio’s API is accessible via HTTP so I think Tap Forms’ Javascript API should be sufficient to make the requests.

    #45707

    In reply to: Aggregate Amount Field

    Brendan
    Keymaster

    Hi Tim,

    Yes you can do this with a Field Script.

    Use this code in a field to display the aggregate total of all the records in the form for the specified field:

    function getFieldTotal() {
       var field_id = 'fld.....'; // whatever the field ID is for the field you want the total of.
       var total = form.getTotalOfField(field_id);
    
       return total;
    }
    
    getFieldTotal();
    #45678
    Sam Moffatt
    Participant

    The other day I had a random thought: could I port the old Drug Wars game that I used to play on my calculator over to Tap Forms 5? Since you’re reading this you probably guessed the answer is yes!

    For those not aware, Drug Wars was a popular game for the TI-82/TI-83/TI-84 series of graphical calculators that one might find in a high school maths class. I found a version of it online in a Gist and set to porting it over to Tap Forms.

    I used some of my prompter support functions (also available via Script Manager), added some helper functions to emulate what the calculator provides and mostly faithfully ported it into Javascript and Tap Forms 5 for Mac.

    Note: this won’t work on iOS because Utils.alertWithMessage on iOS doesn’t block like it does on the Mac. Hopefully Brendan can figure out how to make that consistent, or suggest a change to make it work, so that you can use Tap Forms for iOS and iPadOS to also play the game.

    If you’re interested in checking it out, it’s here in a Gist on GitHub: https://gist.github.com/pasamio/3238964489c6594ab1983b7aaa02b91b

    As a note, it’s a Javascript almost lines for line replication of what the original TI-BASIC programming. It’s hampered a little because TI-BASIC has labels/goto whilst Javascript doesn’t provide that feature (probably because goto considered harmful) so that leads to more creative solutions to flow control. There’s an elegance in how the spaghetti code in TI-BASIC works that perhaps reminds us how things used to be.

    And now to ping the keymaster because I’m sure this post will get flagged…

    • This topic was modified 4 years, 2 months ago by Sam Moffatt.
    • This topic was modified 4 years, 2 months ago by Sam Moffatt.
    #45648
    Miguel Centeno
    Participant

    I was looking to the above script you posted (#post-39818) but I have no idea where str = str.replaceAll(‘Blue’, ‘Red’); is supposed to be placed.

    My goal is to have a Run Script button to change part of a URL, from time to time.

    I’m doing some genealogical research using a particular Chrome extension viewer, which is more user friendly than the original viewer of the archive site. The downside is the extension changes the original URL. So, in the end of the day, after pasting a lot of URLs to TF, I wish to replace a part of those URLs, so I can have the original ones. Basically, to find “viewer” and replace it with “ViewerForm.aspx”:

    https://digitarq.arquivos.pt/viewer?id=4805309&FileID=PT-ADLSB-PRQ-PFAR02-004-M4_m0027.jpg
    https://digitarq.arquivos.pt/ViewerForm.aspx?id=4805309&FileID=PT-ADLSB-PRQ-PFAR02-004-M4_m0027.jpg

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

    Can you post what script you have so far? Then I can see what you need to do to accomplish what you want.

    #45639
    Miguel Centeno
    Participant

    Hi Brendan, I’m afraid my programming skills are too basic, can you please help me with the complete script for that?

    #45634
    Brendan
    Keymaster

    You’d just need to use the JavaScript replaceAll() function for that.

    str = str.replaceAll('Blue', 'Red');

    #45633
    Miguel Centeno
    Participant

    Very useful script but how can I find and replace a specific word in a paragraph?

Viewing 15 results - 1,141 through 1,155 (of 2,989 total)