Does anyone have any suggestions for references on learning the version of Javascript that is supported by TF?
Thanks Brendan, a step by step with the proper syntax and explanation in order to grab a value from a field in one form and insert it into another form. I’m just trying to get a visual utilizing Tap Forms scripting technique.
I can’t grasp the written instruction of how to use java script in Tap Forms without seeing it in use inside the Mac version the program.
You could just add a Script field, then click the Script Editor button to edit the script. Then copy and paste the code in my above example and replace the “fld-….” value with your own photo field ID. It’s right there on the Script Editor screen. Then save it. You’ll now have a field that tells you the number of photos in your Photo field. Now you can build a search on that.
You don’t really need to know how to write scripting code. Just a copy and paste.
Oh, unfortunately I don’t know anything about using a script or writing one.
But thanks for taking the time to answer me, I appreciate that.
Might I please add my support to this request for a scripting video(s)? That would be very useful.
Hi CollectorM,
Yes there is. You can do that by using a Script field that returns the number of photos in your Photo field and then search the form for where that field value is 0.
Something like this will work if you add a Script field to your form:
var case_cover = record.getFieldValue('fld-e2cf02f376864a7cb9f090e4a597f3e4');
if (case_cover) {
case_cover.length;
}
Use the “fld-” value from your own form’s Photo field. You can get that from the Script Editor.
Hope that helps!
Brendan
Hi Joe,
Thanks for the request for a Scripting video. That would be great to have. I’ll see if the guy I hire to do that can make another one.
Is there any specific thing you would like to see scripted?
Thanks,
Brendan
Brendan thank you for your continuous efforts in answering questions on this forum. Been using tap forms for about a year. Mac, IPad, IPhone with syncing. Works well and recommend the app often to IPhone users that I work with. Up to now using TF for keeping track of simple stuff such as hours worked, fuel purchases, work related miles driven. I would like to expand my knowledge and skill to utilize scripting to garner more power from the app. I am politely and respectfully requesting some training videos on how to perform some common tasks specific to the use of this fine software. I have found that with ever changing technology, I seem to grasp concepts and learn more effectively by watching “how to” vids. Looking for just a roadmap utilizing this software. I’ll hang up now and listen for your answer:)
I use this script in a script field to materialise the child values into the parent field to make it searchable:
function recordsLoop() {
var retval = [];
var shipments = record.getFieldValue('fld-db2fcdb4d79c466ea09671c47d2ae645');
for (var index = 0, count = shipments.length; index < count; index++){
var tracking_number = shipments[index].getFieldValue('fld-7a29242731d9451092c92d8586dbc94a');
if (tracking_number) {
retval.push(tracking_number);
}
}
return retval.join(' ');
}
recordsLoop();
fld-db2fcdb4d79c466ea09671c47d2ae645 is a Link to Form field pointing to the child records (shipping entries in this case) and fld-7a29242731d9451092c92d8586dbc94a is the tracking number in that shipping record.
When you’re in the Script Editor for the script field, use the “records loop” snippet on the “Link to Form” field to get most of this boilerplate handled for you.
You could possibly do a Link to Form with a JOIN type to get matches that way and then you could iterate over the values of the Link to Form field. Not quite a 1:1 match to the functionality but you could tie this together with a script field to get the exact value you want out of the children.
Hi FourD,
Sorry for my delay in replying. I just saw your post today.
You can certainly do this with a Script field. You can ask for the array of records from a Link to Form field and then get the values from the field you’re interested in, then concatenate them together.
You could do something like that using a Script field instead of a Calculation field. You’d just have to fetch the values from the field from another form using the value from a field in your current form. I’m sure there’s more nuances to the VLOOKUP function. I’ve just never used it before.
A few thoughts, not sure if these will help solve your problems. I’d start normalising your data a little because that will help you aggregate on those axis (e.g. https://en.wikipedia.org/wiki/Database_normalization).
The first step I’d take is to create a form with hosting provider in it. Each hosting provider is a record in this new form. Then you can use a Link To Form field as either a 1:M or JOIN type to go from the hosting provider to the customer (1:M assuming each website/customer is only hosted at one place, you could do M:M if that isn’t true; if you have a “key” column for the hosting provider in place you can use this for the “JOIN” field, a text field with a controlled value is enough).
Doing this will force you to create a record per hosting provider however the Link To Form inside of it will give you quick aggregations on the numeric fields. See a screenshot of roughly what I mean. This might not be everything you need but you can use scripting to create a text entry with the data you want for that hosting provider. At the very least this makes filtering by hosting provider relatively trivial and building JavaScript aggregations a little easier. It is a little more work to get set up but you should be able to experiment on a backup to see what I mean.
If you go for the JOIN option, you should be able to do this by creating the hosting entries you need. You could automate that but that might be more hassle than it’s worth unless you have a lot of hosting providers. If you go for the 1:M or M:M options, then you need to link all of the records together by hand or again write a script to do it for you. Either of those choices will make sense depending on the volume of data you have and your own inclinations. As always before doing any of these tasks: make a backup first, restore it to a new document and disable any sync you have enabled to prevent changes from propagating. That way if you make a mistake, you can be confident you didn’t toast your only copy.
Attachments:
You must be
logged in to view attached files.
AnonymousInactive
Hi Sam, thanks for the info i’ll try it soon.
I’ve got a Numbers sheet with customer data comprised of names, mail, website, where it hosted, prices etc.
Got most customer fields already in 1 form and prices etc are calculated correctly through scripts. Now I want to make an overview form which show me total prices, average monthly income / expenses, how many websites are hosted with a specific holster etc.
As an example I asked the question because I want to have an overview how many sites are hosted with hosting provider x, y and z. Can’t do that with an calculation (Numbers got an COUNTIFS, tapforms not) and calculations are not updating in my case so I’m using the script function (also gives me more advanced features and also easier for me to understand as a coder)
You need to do a loop for that:
var customers = record.getFieldValue('fld-a538b0e58afa4d5db40dd06a19af2436');
for (var index = 0, count = customers.length; index < count; index++)
{
var name = customers[index].getFieldValue('fld-c4e6710f99544905b9cbbf1fcbd8f613');
name;
}
That will overwrite if you have more than one field linked.
The Script Editor will only display the fields from linked forms however you can copy and paste the field ID’s and keep track of them manually. Linking makes it a little easier but the ID’s in the script itself is unrelated to any links. You can use documents.getFormNamed('Customers').getRecords() to get all of the records in that form instead of using record.getFieldValue.
Do you mind sharing a little about your use case and the problem you’re trying to solve?