Dear Folks!
I don’t know, if this is a bug of if I am to stupid…
In a script I have to call some field values.
For fields in the same form this is no problem.
record.getFieldValue(…)
But if I call a field from another form, I get a error message.
The editor produces this phrase to call the value:
“XXXX.getFieldValue(…)”
“XXXX” is the name of the form, in which is the field, we need the value from.
The error message is: “ReferenceError: Can’t find variable”
Where is the mistake?
Thanks in advance,
Eddy
P.S: My momentary workaround is to create a calculation field in my form, that calls the field value that I need and than to refer in the script to that calculation field. Working, but not really clean.
I should clarify. Using record.getFieldValue(fieldID) returns a date in the standard JavaScript output way. My problem is with extracting year, month, day (etc) values so that I can produce a new date object. I can’t see how to do this.
I want to combine the date from a Date field and the time from a Time field into a value that can be pasted into a Date/Time field.
Using record.getFieldValue(fieldID) on either field type does not return a JavaScript Date Object, but a string with Date and Time info.
Please does anyone know how to extract the year, the month number and the day from a Date field, and the hours and minutes from a Time field?
Thank you, Sam. So I found that this code jumps me to the specified record:
var thisRec = form.getRecordWithId('rec-93d0352d75c64a638dced9515827ac95');
form.selectRecord(thisRec)
Great! But my need is to get TapForms to recognise that the current record is “selected” when I call a script from AppleScript. So I tried:
var thisRecID = record.getId()
var thisRec = form.getRecordWithId(thisRecID)
form.selectRecord(thisRec)
Running this script does nothing visible, of course, because it tells TF to go to the current record. My hope is that it would tell TF that the current record is indeed selected. But when I call this script from AppleScript, I get the same complaint in the console:
“Record ID testing: TypeError: undefined is not an object (evaluating ‘record.getId’), column:23, line:1”
I.e. it simply does not recognise “record” in line 1 as referring to the current record.
Any more ideas?
I had a similar problem the other day and just wrote a small script that concatenates the content of a child field. The result is shown in the script field. Since this is only a helper field and I don’t want to clutter my form, I set the hidden flag on the script field.
const wineryNameId = 'fld-3e98efea365847f3a2569700d679b4ed';
var winesLinkId = 'fld-30dd9906b79649b6b54c01603928901d';
function joinChildField(childLinkId, fieldId){
let entries = record.getFieldValue(childLinkId);
var list = Array();
for (entry of entries){
list.push(entry.getFieldValue(fieldId));
}
return list.join(', ');
}
joinChildField(winesLinkId, wineryNameId);
In order for you to use this field script, you have to set the different field ids. wineryNameId is the field in the child form. winesLinkId is the linked field pointing to the child form.
The operation of this script is very similar to what Sam posted. It is simpler as it doesn’t contain any logging features. The only thing you have to do is updating the two field ids.
Obviously, it would be nice if search would go through child records, if requested. And then only show child entries that match.
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks
Hi George,
You’re right. Tap Forms does not search down multiple levels of relationships.
But you can work around that by writing a Field Script which loops through the child records and builds a string that can be displayed and searched on the parent form.
Use the Child Records Loop snippet to loop through your child records. Then pick out a value from the record to concatenate to a string. Return that value and then you will be able to search that string.
function recordsLoop() {
var actors_id = 'fld-984cf79ccafb45a381b0f95b0aa28e78';
var last_name_id = 'fld-a907066570844290a27940d34de98b4f';
var actors = record.getFieldValue(actors_id);
var last_names = [];
for (var index = 0, count = actors.length; index < count; index++){
var last_name = actors[index].getFieldValue(last_name_id);
if (last_name) {
last_names.push(last_name);
}
}
return last_names.join();
}
recordsLoop();
Probably not as convenient as what Air Table has. I just read an article in the BBC News that they’re worth a billion dollars now. So I suspect they have lots of engineers working on the app and can do some things that Tap Forms can’t do yet. I’m just 1 guy :)
Thanks,
Brendan
I’m a little confused because if you have two forms, one for wines and one for stores, which have a many to many link between the two and you’ve ticked the “show inverse relationship” on both sides (make sure to toggle it if you changed the type to delete and recreate the field), then on both sides you should have a multicolumn list view embedded in your record that gives you what I suspect you’re after (e.g. when looking at a wine, you can see which stores you linked). Try setting Many to Many and then toggling the “show inverse relationship” option on the “Link to Form” side of the relationship. This should be ok on either a Mac or iOS though I always go and double check it removed the field after toggling it off and then going all the way back to toggle it back on (that’s much easier on the Mac).
On another tangent, I think this might be similar to an earlier thread on how to filter using fields in two linked forms. The suggestion I made there is that it might help to have a third form, in this case I’d probably call it “purchase”. The “purchase” form has a 1:M link from wine to purchase and 1:M link from store to purchase, maybe put a date in as well. Then you can use that inner form to track which store your wines came from and when.
It could also be that the indexing in general is problematic and you need to copy the values from the linked forms into the parent. I wrote an example of how you can use a script field to copy values from linked records to help them show up in indexing.
I think maybe the Link from Form field might have gotten fried so give that a spin first because this should be working. Otherwise the other ideas might help you out. I’d suggest the middle one is useful to do because it let’s you track individual purchases but maybe you’re less OCD than me :D Good luck!
Well in the next update of Tap Forms I’ve added the ability for you to get access to the Pick Lists, so you could use them that way if you like from a script.
I appreciate the help, but this is proving really problematic. If the record that I want to work with is the active record in the form, why does TapForms think the record is “undefined”, just because I’ve called the script from an AppleScript? The script works when I just run it from within TapForms, but I want a simple way to successfully call from AppleScript a script that will act with the current record.
In addition – testing out functions from the TapForms JavaScript API web page, I edited my script to read simply:
function New_Script() {
form.selectRecord()
}
New_Script();
Every time I run this script by clicking the “Run” arrow, TapForms crashes.
Thanks for your idea, Brendan!
But what we need is a phrase, that we can use in scripts and fields.
Did you thought about equipping tapforms with the ability to have constants? – Somehow, we already have something like that. The picklists. So, that preferences window would be the perfect place, to store phrases to be used tapforms wide.
Regards, Eddy
Well, if you are creating a custom layout for your emails, you can add a static Text object to your layout and then type in whatever text you want to appear there. Such as your company address, email, phone number, etc. That text will appear on your custom layout for every record when you print/email your records.
That’s another idea.
But also Sam’s idea of having a single Form script to store a bunch of information like that which you can pull up from field scripts is a great idea too.
I’d probably use the runScriptNamed functionality and then define the common values in a form script. You then load the form script anywhere you need to use them and it’s a single place to change. That could be populated into a field that you can refer to from a calculation field or obviously it’d work natively in a script field.
Hi Folks!
Actually I am falling in love with this app… In the meantime, we are starting to create even our CRM with it.
Doing this, I have a task/problem:
Some text phrases and numbers of us will I have to change time by time. For example the footer of our emails. Of course, I do not want to rewrite all the scipt and calculation fields than. Therefore, I do not want to write our footer (signatures) text in the script and calculation fields directly…
But how (where) can I store text phrases, so that they will be replaced everywhere I used them in scipt and calculation field, if I change them?
Sorry for my poor English and thanks in advance.
Eddy
I’ve made this form to plan my blog and social media posts. The original is in my bilingual English/German = Denglish, but I have copied it and put the headings into English. You might have to adjust the lists, though. I’ve noted in those areas that you will need to work on to make it your own.
Also you might want to adjust any bilingual entries. They usually are self explanatory; but, as I am an illustrator, some of the theme topics that are relevant to me won’t be of interest to you. And in the keywords section, you might want to change the last list entry of “language” to whatever language(s) you are targeting.
I think the really nice part of this form is the part for the keywords search. Brendan had written a little script to change your keywords into hashtags. That makes it really convenient to copy and paste them into where ever your posting to. You can use the filter to search out the top 25 hashtags for yourself and your business.
The forms aren’t styled any particular way, I found that these work best in their straightforward manner, but you can design them as you wish.
Good luck and happy planning. If you like it, let me know. I would love the feedback.
(You know, we could share styled forms on Twitter ( you can tag me @)visualitysenses and Instagram (@hoffmanillustrates).
Regards,
Kimberley
Attachments:
You must be
logged in to view attached files.
I’d expand a little on Daniel’s approach and actually suggest two forms: one for your products and then a linked form would be the individual batches. The reason for that is that you can look up your products as top tier entries and then see all of the linked batches. I’d put the form script then in that product form and create a new linked record batch records that are linked. This will save you some database traversal where you’re only looking at linked records for the individual product. You could also do some more optimisation with extra lookup fields to speed up creating new records though you can iterate through record lists in Tap Forms pretty quickly.