Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
February 13, 2022 at 7:36 AM #46722
In reply to: Simple Prompter for adding via Siri
Prashant M
ParticipantHI Sam ,
Thanks for the reply ,as always they are really appreciated.1. The snippet you’ve showcased from your script , this is to be added “where” ? in Shortcuts to be defined as a variable “message” ?
February 12, 2022 at 11:30 PM #46717In reply to: Help with a script
Stig Widell
ParticipantSam, it is early Sunday morning here and I slept thinking of the Kalva script.
You said the script is working because it was your intention to manually enter the eartag number in Avelstjur. I said it didnt work because I expected script to enter the number by matching grupp.After all cows have calved I sell (in November) the males and some of the females in form Kalvningar and I am no longer concerned about the father of these calves. The female calves I keep will be transferred over to the form Rekryteringsdjur (hopefully by a separate script further on).
So I am not too worried about mutation?Of course I can restructure but I would ask you to help me with that I am not experienced enough.
But wouldnt it be easier just to look for a match in grupp in Rekryteringsdjur and Avelstjurar?February 12, 2022 at 5:32 PM #46715In reply to: Help with a script
Sam Moffatt
ParticipantThere is no search, it grabs the value of Avelstjur from the current record because that’s a single value and one assumed to be the primary key. The code I used is based on the assumption that there is only a single primary key match. The grupp fields are configured as pick lists for which that assumption doesn’t hold.
Ideally you’d restructure to have grupp be it’s own form and then have that grupp contain a link to form field 1:M pointing on one side to the Rekryteringsdjur record and then from the Avelstjur a link to form field 1:M going to the Grupp. Then in Rekryteringsdjur you would have a single entry pathway from Rekryteringsdjur to Grupp to Avelstjur (though this model does mean a bull could be configured to be in two Grupp at the same time, Tap Forms doesn’t have a 1:1 link type which would potentially catch this).
The downside of all of this is if you change the metadata in time then the links become out of sync again because there is no temporal coherency to the values, especially once you start automatically updating records. This is what makes your use case slightly more complex in that over time I would expect that some of the values will mutate in non-predictable and hard to script ways.
February 12, 2022 at 2:57 PM #46714In reply to: Help with a script
Stig Widell
ParticipantYou wrote this earlier:
The Kalva function is there to create the calf, the first set of lines set up the various field ID’s we’re going to need later and then grabs the Avelstjur value for the current record. If that isn’t set we have an error message and return. It then looks for a match of that ID in the Avelstjurar form and if it doesn’t find it, also returns out. I did fix the type to match as number with the same formatting everywhere because I think initially it didn’t match properly due to a type mismatch (Javascript is a little more picky than TF).I cannot find that you are comparing the grupp field in form Aveltjurar with the grupp field in form Rekryteringsdjur? When these two match we have the correct Avelstjur and the father of the calf? That should be the crucial point.
So my question is: is there a search for match between the grupp fields in the two forms in the script Kalva??February 12, 2022 at 1:10 PM #46708In reply to: Help with a script
Stig Widell
ParticipantYou created the script Kalva to identify the field Avelstjur in form Rekryteringsdjur as I understood it??
February 12, 2022 at 1:05 PM #46707In reply to: Help with a script
Stig Widell
ParticipantBut the intention was not to use picklist at all but to let the script identify Avelstjur when grupp is the same in form Avelstjurar and form Rekryteringsdjur?
February 12, 2022 at 12:03 PM #46705In reply to: Help with a script
Stig Widell
ParticipantYes I know but why is the Avelstjur in form “Rekryteringsdjur” empty? The script should identify Avelstjur when field “grupp” is the same in records in form “Avelstjurar” and in form “Rekryteringsdjur”. When I insert a bull via picklist in form “Rekryteringsdjur” a calf record is created.
February 12, 2022 at 9:55 AM #46703In reply to: Help with a script
Sam Moffatt
ParticipantThe screenshot shows that Avelstjur is empty? It uses that field to determine the bull ID, with it empty then the script can’t find the bull to link to the child record.
February 12, 2022 at 1:27 AM #46702In reply to: Help with a script
Stig Widell
ParticipantOK Sam,
The font problem is fixed with Brendan´s help.
The script problem is still there.February 11, 2022 at 1:05 PM #46691In reply to: Help with a script
Sam Moffatt
ParticipantThat should only fire if Avelstjur is not set on the record you have selected in the Rekryteringsdjur form. If you’ve created a new field or are using a different field for the ID of the bull then you’ll need to update the field ID to match the new field ID on this line:
let keyValue = record.getFieldValue('fld-db52d7055ddd40cf95f50bcf8e2fff3d'); // ID of the Avelstjur field in Rekryteringsdjur form.The field ID is below the field description box which you can copy from there.
February 11, 2022 at 12:55 PM #46690In reply to: Pick list sort order (2nd)
Sam Moffatt
ParticipantI added this to my Script Manager so that if you want to set this up for a new script field it can look like this (once Script Manager is installed and update run):
document.getFormNamed("Script Manager").runScriptNamed("PicklistID"); PicklistID('fld-fa37906add2942c88bce3b500561c42d', 'Marketplace');One minor change was to fix an issue where the pick list was returned at the end if nothing was found and that now is returning a null that should show up as an empty value for the field (it was showing up was something like
[TFPicklist object]I think).February 11, 2022 at 12:32 PM #46689In reply to: Help with a script
Stig Widell
ParticipantSorry Sam but now when I run the Kalva script I am always stopped by this part:
// check if the bull is even set or error.
if (!keyValue) {
Utils.alertWithMessage(“Fel!”, “Avelstjur värde ej inställt!”);
return;
Whats the problem?February 11, 2022 at 10:01 AM #46686In reply to: Simple Prompter for adding via Siri
Sam Moffatt
ParticipantYeah, you need to return to Shortcuts after the execution. I only recently figured this one out, here is a quick snippet from one of my scripts:
if (parameters && parameters["x-success"]) { Utils.openUrl(parameters["x-success"] + "?message=Updated%20existing%20record&tfrec="+ targetRecord.getUrl()); } else { form.selectRecord(targetRecord); Utils.openUrl(targetRecord.getUrl()); } return "Updated existing record for " + clipboard;I also updated the shortcut so that it displayed the result text as a notification and then bounced me back to Tap Forms. I need to work on figuring out if I can update the UI before the bounce to have me land back on the record after the script completes.
Also attached a screenshot of the end of my Shortcuts that pairs with that script snippet.
Attachments:
You must be logged in to view attached files.February 11, 2022 at 6:00 AM #46683In reply to: Pick list sort order (2nd)
Mathieu Masseboeuf
ParticipantOh, indeed I didn’t noticed that answer !
(just tried with the ascii stuff, but I would have to refill everything, or script a replacement)Indeed, last time I checked TF didn’t had scripting, never used it … will have to check that out :P
February 10, 2022 at 11:29 PM #46679In reply to: Simple Prompter for adding via Siri
Prashant M
ParticipantHI Sam,
I’ve looked at the video you provided and I was able to call the script to work using ShortCuts .I did notice that the shortcut keeps working in the background & I need to manually stop it ,
is there a way to stop the same ? -
AuthorSearch Results