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,546 through 1,560 (of 2,952 total)
  • Author
    Search Results
  • #42818
    Victor Warner
    Participant

    I wish to create a script which searches one Number field. If there is nothing there then use another Number field. However, if the first number may have nothing in it (not even a zero), but I cannot work out the search criteria for an empty number field.

    For example:

    if (upper_figure == ”) {
    return total_charge_with_fixed_amount;

    }

    does to produce the desired result if the upper_figure is empty. Nor does

    if (upper_figure == null) {
    return total_charge_with_fixed_amount;

    }

    What is the correct syntax for an empty Number field?

    #42811
    Sam Moffatt
    Participant

    Case 1: I’ve got a form with 124 fields in it and I personally don’t understand the problem you’re talking about (125 now because I added a test field at the end to see what it did which was focus the field title text box). It doesn’t seem to disrupt me though I might be missing something obvious.

    Case 2: Forum is reasonably generous at uploads as well with a max upload size of 4MB, a lot of use cases I manage to fit in that (use smaller window size, don’t record in retina resolutions, squeeze the frame rate down to 15 fps if it isn’t there already). For those that don’t, I put videos on YT as you can upload them as unlisted and get a private link to share.

    Sync
    Many applications use iCloud to sync in the same way as Tap Forms does, including many Apple apps like Contacts, Notes and more. Agenda is another app I use with iCloud that as changes are made on one device, they become available on all devices. Almost any multiuser based synchronisation system will sync changes as they are made not when you close the document because then you have to wait to upload the data. I would expect any sync solution to be progressive, especially on iOS where you only get time to do work whilst your app is active. iCloud does seem to have issues especially relating to rate limits on non-Apple products which is why I’ve consistently recommended youor own CouchDB for higher throughput.

    If you want a sync solution where you open the document, you are the only one who makes changes to it and then save it back, you copy your Tap Forms documents to and from more traditional folder sync platforms like Dropbox or iCloud Drive. This would only work on the desktop and there was an earlier thread that described the process. Seems like it worked for them, might work for you. The important thing is that he’s quitting TF and copying the document to and from shared storage each time. If you edit your TF document there directly on two devices, it can corrupt the database as noted in that thread. You could do some scripting to automate this to make it smoother as well.

    All told it’s also been noted that Brendan is working to implement another sync backend rather than CouchbaseLite that would add support for Dropbox back though it might be the simple file you are expecting.

    reimport: if you’ve got concise use cases you can share where you notice data being transformed inconsistently then I have to assume that would help get any bug that exists fixed, I know in my own coding that when I’ve introduced a bug a concise reproduction case is great for testing and validating the fixes.

    Woocommerce: interesting use case, why round trip the data through Tap Forms though? Why not build something in PHP to work with the database or manipulate the data export directly if the ultimate aim is to import back to Woocommerce? Alternatively is there an API for Woocommerce you could use via the Javascript API to more directly interact with the platform?

    #42807
    Daniel Leu
    Participant

    Hi Victor,

    I created a new script field underneath the table and use following code:

    function Third_Party_Charges_Csv() {
    
    	// Fetch content from table
    	var third_party_charges = record.getFieldValue('fld-021cfb3cc4f446ddbf5f9463c7b5d620');
    
    	// Define field ids from table columns
    	const item_id = 'fld-410bdf5d624a4651b8a803becd9c6578';
    	const cost_per_item_id = 'fld-6cea4aa73ad44b6f91ba7f566e321790';
    	const number_id = 'fld-95791fbc24bd4f3ca714756e5dd6a060';
    	const cost_id = 'fld-a0be1b009c6a4a99a1784d36da134ee3';
    
    	var txt = [];
    	
    	// Loop over all entries and fetch field content.
    	for (var n = 0; n < third_party_charges.length; n++){
    		var third_party_charge = third_party_charges[n];
    		var item = third_party_charge.getFieldValue(item_id);
    		var cost_per_item = third_party_charge.getFieldValue(cost_per_item_id);
    		var number = third_party_charge.getFieldValue(number_id);
    		var cost = third_party_charge.getFieldValue(cost_id);
    	
    		// Format field content as desired
    		txt.push(n + ". " + item + ": £" + cost_per_item + " x " + number + " = £" + cost);
    	}
    	
    	// Combine each formatted table row
    	return txt.join(" - ");
    
    }
    
    Third_Party_Charges_Csv();

    If you want to import this as a CSV into a spreadsheet, you might run into an issue with the ‘-‘ character. It is used as line separater and inside the FCO item.

    Hope this helps!

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #42805
    Victor Warner
    Participant

    In a form I have a table field which contains a number of records.

    I wish to export the contents of a number of the fields to a CSV (or XLSX) file. But the table field are not exportable.

    Is possible to extract the contents of the table field into an another field through a script?

    In the attached document the table field (called ‘Third party charges’) contains two records:

    Legalisation agent (normal service) £24 1 £24.00
    FCO – apostille (normal service) £30 1 £30.00

    I would like to combine so they become in another field such as (for example):

    1. FCO – apostille (normal service): £30 x 1 = £30.00 – 2. Legalisation agent (normal service) = £24 x 1= £24.00

    Can a script do this and how would I do it?

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

    In reply to: Calculations Tutorial

    Brendan
    Keymaster

    Hi Andy,

    There is a video that shows the basic usage of the Formula Editor here:

    It’s at 5:45 in the above video.

    The description of all the functions available are here:

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

    There are four conditional functions. There’s IF(), IFEMPTY(), IFNOTEMPTY() and the IFEQUAL().

    They all are based on the concept of logic such that if something happens, then do this, otherwise do that.

    For example:

    IF(Price < 0; 0; Price)

    What this means is that if the value of the Price field was less than 0 (negative), then make it 0. Otherwise, just return the Price if it’s 0 or greater than 0.

    The other ones work on the same principal.

    IFEMPTY(Price; 0; Price)

    If the Price value is empty, then return a 0, otherwise return whatever the Price value is.

    The IFNOTEMPTY() function is just the opposite:

    IFNOTEMPTY(Price; Price; 0)

    The IFEQUAL() function is only a little different as it takes 4 parameters and is used for comparing strings rather than numeric values like the basic IF() function.

    IFEQUAL(Field A; Field B; "Equal"; "Not Equal")

    So in the above, if the value in Field A is equal to the value in Field B, return the text “Equal”, otherwise if they’re not equal, return the text “Not Equal”.

    And that’s all there is to it.

    Hope that helps!

    • This reply was modified 2 years, 11 months ago by Brendan.
    #42802
    martin c
    Participant

    case one expectations ::

    stay put!! not jump to the first field, coz i want maybe?? do other changes to it, then again jump… so do you understand that jumping at 50+ fields can be a problem??

    case two::

    sure video is great, but not at 4mb atachment limit, where can i send it?? else??

    sync::

    icloud!!

    so, the sync can not happen until you will: by saving, colsing dokument, a situation you are sure you do accept the work…. thats the idea of saving, not saving…. it can not be done on every little change, cos it leads to problems like we have here>> destroying project!! why?? simple solution ::: dokument in the icloud as real file, on storage, accesible via finder, opening closing saving file then the sync… every app does it that way…

    reimport::

    just wanted to check the conistity of data!! it fails, fields fall apart, records are empty etc…so its the eport or import failure?? is the data exported well?? can i trust??

    my case:::

    i doing a database work on woocommerce eported csv of products from the shop, 50+ fields , a photo field, where i wanted the filename script to generate filnames in a field, cozz i need it on reimport to woocommerce… its a kind of inventory with photos, kind ob batch modification of fields , all cozz the import of products to worpress woocommerce…

    thx

    #42783
    martin c
    Participant

    ok …. thx a lot … the script is working well ..!!

    the other thing I can’t get to work ::

    I read the manual on multicolumn edit …

    Still have this issue that if I select a cell non of the other panels update FOCUS to this cell >> panel view , in the form , the fields view etc ..

    Is this by design ?? Should it work so ?? .. is there any way to have this panels synced up in view /cell selection in the multicolumn view ??? any magic option I could not find ?? sorry maybe its that easy …. but the pics in the manual are from older versions …. can’t figure it out …

    thx ..

    #42757

    In reply to: Duplicating records

    Andrew Jolly
    Participant

    Thank you. I understand what you’re trying to do but what do I do with that script you’ve created?

    #42756

    In reply to: Duplicating records

    Daniel Leu
    Participant

    TapForms doesn’t provide native support for this, but you can implement this using its scripting engine. Although my example shows how to copy data between documents where ALL FIELDS are identical, you can do this between forms as well. Again ALL FIELDS need to be identical!

    Details are at https://lab.danielleu.com/blog/copying-record-data-between-documents/

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #42736
    Brendan
    Keymaster

    Hi Martin,

    Are you using the multi-column list view? If so, configuration of that is done separately from the single-column list view and the record details view. See this topic in the help manual for info:

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

    Look for the sub-topic Editing the Multi-Column View.

    Perhaps that’s why you’re not seeing things sync up or some fields not showing up. You can control that all separately from the other views.

    Here’s a script to loop through the array of photos to get a list of the photo filenames:

    function Photo_Names() {
    	var photo_filenames = [];
    	var case_cover = record.getFieldValue('fld-54ed276ee9054d73843865f9c716e851');
    	for (var index = 0, count = case_cover.length; index < count; index++){
    		var photo = case_cover[index];
    		photo_filenames.push(photo["filename"]);
    	}
    	var filenames = photo_filenames.join(", ");
    	return filenames;	
    }
    
    Photo_Names();

    I’m not entirely sure what you want to do with them, but there it is. It will just log a list of the filenames.

    #42733
    martin c
    Participant

    ok …

    at first :: I select a cell >> then I have it in an form / a field property / the list view etc all the panels I can have for that cell/entry/single value .. it does not select on it own … so in every window/panel I have to scroll, choose the option/cell etc … disaster :) It should be all syncd to each other , so I select a cell or a position in a form and I get all the actual values in all panels like selection in all the current views/options >>> efficient workflow ??? bidirectional , no matter where selected from ….

    I have strange behaviour with the app … inconsistent … some fields showing up , some not , if I move the photo field on top it does not update in the list view etc … try to uninstall/reinst. the app … some liquid feeling :)

    ok … I give the script a chance :)

    thx …

    #42731
    Brendan
    Keymaster

    Hi Martin,

    When you edit a property for a field I do refresh the form because the changes you make do affect the display of the form. So that’s normal behaviour.

    I’m not sure about the photo field issue though. Nor the issue with jumping around when editing a property. Are you referring to the field properties not being the right properties for the selected field? I’m not seeing that behaviour.

    For the Photo field, you can’t reference a photo field in a formula.

    But you can in a Script field. A Photo field is basically an array of dictionaries. So when you ask the record for the value of a Photo field, that’s what you’ll get. There’s a filename property in the dictionary you can get to give you the value of the filename.

    Thanks!

    Brendan

    #42722
    Paul Wirth
    Participant

    Thank you so much, Brendan, for getting this feature started so quickly! Adapting your example, and after some messing around with the Mailchimp API docs and curl, I came up with the following:

    function Fetch_From_Mailchimp() {
    	var server_prefix = 'server-prefix'; // log in to mailchimp; the base url will be something like 'us19.admin.mailchimp.com'. in that example, 'us19' is the server prefix 
    	var api_key = 'mailchimp-api';
    	var list_id = 'id-of-audience-list'
    var response = Utils.getJsonFromUrlWithHeaders('https://' + server_prefix + '.api.mailchimp.com/3.0/lists/' + list_id + '/members?fields=members.id&count=10&offset=0', {"authorization" : "Basic " + api_key});
    
    return response;
    }
    
    Fetch_From_Mailchimp();

    This returns a list of the first 10 member id’s from the given list id.

    Next I’ll need to work on parsing member info through the API and updating the Tap Forms list. I’m a beginner with javascript, so that’ll be a learning project.

    #42698
    Brendan
    Keymaster

    I’ve been working on this (as a side project to the big project).

    Since I already have a Campaign Monitor account, I found they have a REST API too:

    function Fetch_From_Campaign_Monitor() {
    	var api_key = 'my-campaign-monitor-api-key:x';
    	var api_key_encoded = Utils.encodeBase64String(api_key);
    	console.log(api_key_encoded);
    	var response = Utils.getJsonFromUrlWithHeaders('https://api.createsend.com/api/v3.2/clients.json?pretty=true', {"Authorization" : "Basic " + api_key_encoded});
    	return response[0];
    }
    
    Fetch_From_Campaign_Monitor();

    Seems to work. I had to add the Utils.encodeBase64String() function because I couldn’t find a way to do that with JavaScriptCore.

    #42694
    Sam Moffatt
    Participant

    If you’re already doing local web development, just modify your scripts to call http://localhost in Tap Forms and call out to your local environment. Then you can use the scripting language of your choice in that environment to call in with the extra headers to the other APIs.

Viewing 15 results - 1,546 through 1,560 (of 2,952 total)