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 - 931 through 945 (of 2,951 total)
  • Author
    Search Results
  • #46722
    Prashant M
    Participant

    HI 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” ?

    #46717

    In reply to: Help with a script

    Stig Widell
    Participant

    Sam, 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?

    #46715

    In reply to: Help with a script

    Sam Moffatt
    Participant

    There 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.

    #46714

    In reply to: Help with a script

    Stig Widell
    Participant

    You 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??

    #46708

    In reply to: Help with a script

    Stig Widell
    Participant

    You created the script Kalva to identify the field Avelstjur in form Rekryteringsdjur as I understood it??

    #46707

    In reply to: Help with a script

    Stig Widell
    Participant

    But 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?

    #46705

    In reply to: Help with a script

    Stig Widell
    Participant

    Yes 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.

    #46703

    In reply to: Help with a script

    Sam Moffatt
    Participant

    The 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.

    #46702

    In reply to: Help with a script

    Stig Widell
    Participant

    OK Sam,
    The font problem is fixed with Brendan´s help.
    The script problem is still there.

    #46691

    In reply to: Help with a script

    Sam Moffatt
    Participant

    That 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.

    #46690
    Sam Moffatt
    Participant

    I 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).

    #46689

    In reply to: Help with a script

    Stig Widell
    Participant

    Sorry 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?

    #46686
    Sam Moffatt
    Participant

    Yeah, 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.
    #46683
    Mathieu Masseboeuf
    Participant

    Oh, 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

    #46679
    Prashant M
    Participant

    HI 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 ?

Viewing 15 results - 931 through 945 (of 2,951 total)