Help with a script

Viewing 70 reply threads
  • Author
    Posts
  • February 2, 2022 at 12:16 PM #46577

    Stig Widell
    Participant

    Hi,
    Is anyone willing to help a Swedish farmer with a record script in his cow data base?
    No knowledge in JavaScript!
    Brendan Duddrige has helped a lot with two earlier scripts but is too busy now for a third one.
    Will send document via e-mail.
    Regards
    Stig Widell

    February 2, 2022 at 12:25 PM #46578

    Stig Widell
    Participant

    Sorry Brendan, Duddridge it is!

    February 2, 2022 at 10:00 PM #46580

    Sam Moffatt
    Participant

    If you post your scripts to date and maybe the form template folk on the forum can probably help. One of the cool things about the forum is that everyone can benefit from your questions and any solutions :)

    February 3, 2022 at 1:03 PM #46591

    Stig Widell
    Participant

    I need to upload the complete document with 3 forms. But it is 39 MB in a zip version. How do I proceed?

    February 3, 2022 at 1:38 PM #46592

    Sam Moffatt
    Participant

    So I don’t think you need to upload all of the document, see if you can export a form template of the forms which should be much smaller. If you’ve got links setup, Tap Forms should also export the linked forms automatically into a single form template so what I usually do is create a new Tap Forms document, import the form template and make sure it has all of your forms. If it’s missing a form, export that one independently. Then you can upload the form templates (much smaller file size) to the forum with your question.

    February 4, 2022 at 12:30 PM #46597

    Stig Widell
    Participant

    OK Sam, thanks for your help. I think I managed to create a template which is now enclosed!!
    I dont know if I should upload the file in tfarc or tff so I uploaded both.
    Also enclose the requirements.
    I really hope for help!!!

    Attachments:
    You must be logged in to view attached files.
    February 5, 2022 at 11:10 AM #46603

    Sam Moffatt
    Participant

    So to pull the text in:

    This is the case:
    Calf production is a one-year cycle.
    1. In the winter the cows and pedigree bulls are fed separately in my barn. In the summer cows are on pasture together with a specific pedigree bull. I have 5 pedigree bulls (in the form “Avelstjurar”) which are split in 5 different pasture groups identified with a grouping Id (“grupp”).
    2. The cows start calving now in March 2021. At calving (year 2021) I give every cow (in the form “Rekryteringsdjur”) one of the five groupings (grupp) for the pasture season to come.
    3. Hopefully the cows will deliver a calf in spring 2022. I will in an easy way then be able to identify the father for each of those calves born in 2022.
    4. When groupings for a cow and bull match, the bulls ID (“Djur-ID” in the form “Avelstjurar”) should be inserted in the field “Avelstjur” in the cow’s record in the form “Rekryteringsdjur”.
    5. At birth of a calf (year 2022) I link the calf’s record in the form “Kalvningar” to its mother’s record in the form “Rekryteringsdjur” and then the information in the field “Avelstjur” should be transferred over to the field “Fader-ID” in the calf’s record in the form “Kalvningar”.

    So partially I wonder if this isn’t something that can be handled with a creative JOIN field for point 4. However “Avelstjur” is a single text field, how do you structure the data for the next year? Is it all re-entered from scratch?

    Even more curiously, why not just create the calf record as it’s gestating as it would have all of that information already? You can allocate an ear tag for it and then if it doesn’t come to term you also have a record of those as well.

    February 5, 2022 at 2:18 PM #46604

    Stig Widell
    Participant

    So partially I wonder if this isn’t something that can be handled with a creative JOIN field for point 4. However “Avelstjur” is a single text field, how do you structure the data for the next year? Is it all re-entered from scratch?

    “Avelstjur” shouldnt be a text field but a number, my mistake.
    Yes, if I change that field to a join field I get the pedigree bulls info over to the cows record as a list with one row with all the info of that bull. But I cant get the ID of the bull over to the father-ID field in the record of the newborn calf when I link that calf record to the mother record. How do I manage that? What do you mean with “creative” join field?

    Even more curiously, why not just create the calf record as it’s gestating as it would have all of that information already? You can allocate an ear tag for it and then if it doesn’t come to term you also have a record of those as well.

    How do you mean the calf record should be created? I dont understand that? I dont have all information already before the time of birth of the calf, eg date of birth, sex, stillborn etc.

    Did you use the tff file or the tfarc file? what is the difference?

    Thanks for your concern!

    February 5, 2022 at 11:03 PM #46605

    Stig Widell
    Participant

    … and the Father-ID in the calf record should remain the same even when the mother, the year after, will be linked to another pedigree bull 🤔

    February 6, 2022 at 11:40 AM #46614

    Sam Moffatt
    Participant

    Doing this backwards, don’t mind me…

    the Father-ID in the calf record should remain the same even when the mother, the year after, will be linked to another pedigree bull

    Right, the calf record should remain unchanged though presumably at some point it either is sold or grows up into one of the other forms. Which actually makes me wonder if ideally everything would be one form with relevant sections but I don’t think TF does self joins well (data model quirk).

    How do you mean the calf record should be created? I dont understand that? I dont have all information already before the time of birth of the calf, eg date of birth, sex, stillborn etc.

    Well you know what you know about the calf to be, you’re just entering it in immediately once you know some of the details just not all of the details. For me personally I find pre-entering partial data slightly easier because then it’s just a matter of inputting the final data once that comes in. Presumably you know which of your cows are calving so that can be a filter there to limit the possible candidates and you could also sort/group by the pasture they’re in.

    “Avelstjur” shouldnt be a text field but a number, my mistake.
    Yes, if I change that field to a join field I get the pedigree bulls info over to the cows record as a list with one row with all the info of that bull. But I cant get the ID of the bull over to the father-ID field in the record of the newborn calf when I link that calf record to the mother record. How do I manage that? What do you mean with “creative” join field?

    Type is mostly inconsequential for the simpler data fields (text/number) and more necessary for formatting than anything. That said it might mess up some comparisons so always useful to keep it consistent.

    Workflow wise I think I’d create the calf record first and then just link in the mother and father records from the calf directly. Or create the calf from the mother record and then just link it to the father at that point in time. That’d obviate the need to script because you could just use the UI to select.

    I’m going to use one of my scripts to get the ID, easiest way to do this is to import the Script Manager and in the “Repository” form run the “Update Scripts” form script.

    Inside “Rekryteringsdjur” I created a new form script called “Kalva” and then this is it’s implementation:

    let PARENT_SCRIPT = "Kalva";
    document.getFormNamed("Script Manager").runScriptNamed("getRecordFromFormWithKey");
    
    function Kalva() {
    	let rekryteringsdjur_kalvningar_id = 'fld-cdb4431a905f4b1dbaa750b07a63b6f1'; // ID of link to form field to Kalvningar form in the Rekryteringsdjur form.
    	let avelstjur_kalvningar_id = 'fld-35f714dc0468447c9b5b9875c8a86545';  // ID of link to form field to Kalvningar form in the Avelstjur form.
    	
    	let foldse_id = 'fld-8e0cd05ffe8d4603a8abb8ca4694b4ee'; // foldse field ID from Kalvningar form.
    	
    	let keyFieldId = "fld-0e776009803a4c1f8415e7cbb7919858"; // ID of the Djur-ID field in the Avelstjurar form.
    	let keyValue = record.getFieldValue('fld-db52d7055ddd40cf95f50bcf8e2fff3d'); // ID of the Avelstjur field in Rekryteringsdjur form.
    
    	// check if the bull is even set or error.
    	if (!keyValue) {
    		Utils.alertWithMessage("Fel!", "Avelstjur värde ej inställt!");
    		return;
    	}
    
    	// look for matching bull ID record; note this assumes the bull ID is unique.
    	let avelstjurRecord = getRecordFromFormWithKey("Avelstjurar", keyFieldId, keyValue)
    	if (!avelstjurRecord) {
    		Utils.alertWithMessage("Varning", "Det gick inte att hitta posten!");
    		return;
    	}
    
    	// Create a new calf record from the rekryteringsdjur form.
    	let kalvningarRecord = record.addNewRecordToField(rekryteringsdjur_kalvningar_id);
    	
    	// set foaling date to current date.
    	kalvningarRecord.setFieldValue(foldse_id, new Date());
    
    	document.saveAllChanges(); // flush out model changes for new record creation.
    	
    	// add the calf to the bull's record ID.
    	avelstjurRecord.addRecordToField(kalvningarRecord, avelstjur_kalvningar_id);
    	
    	document.saveAllChanges(); // save adding calf to bull
    
    	Utils.alertWithMessage("Gjord!", "");	
    }
    
    Kalva();
    

    The first two lines setup a variable some of my scripts use to identify themselves and import the getRecordFromFormWithKey function. If PARENT_SCRIPT isn’t set, some of the child scripts run self tests on import.

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

    Once we’ve got the bull, we’ve started already with the mother, so we create a new calf from the mother (record.addNewRecordToField). This will automatically set the link from form field to this record. I also set Födelse to the current date, you could also default this in your form settings but this is an example of how you can set some fields in that child record. There is a document.saveAllChanges() because when you create new records, sometimes the scripting system can get out of sync so I find it easier to force a save here.

    The last step is to add the calf to the bull and then save that change.

    That should do the trick for what you’re after.

    Did you use the tff file or the tfarc file? what is the difference?

    TFF is a form template, it just has the definition of the form and linked forms. TFARC is an archive that can also include records. I did the TFARC first then noticed I was missing a form and used the TFF.

    • This reply was modified 2 years, 2 months ago by Sam Moffatt. Reason: fixing blockquote tags
    February 6, 2022 at 12:14 PM #46623

    Stig Widell
    Participant

    I am really grateful to you Sam. I dont have the time tonight (Swedish time) to work with it but I have an initial question:
    “I’m going to use one of my scripts to get the ID, easiest way to do this is to import the Script Manager and in the “Repository” form run the “Update Scripts” form script”.
    This is not for me to do? You did it when you created the form script, right?

    February 6, 2022 at 1:49 PM #46624

    Sam Moffatt
    Participant

    You need to import the Script Manager TFARC to get two extra forms in your own document and run it locally, it imports my library of scripts automatically. The script I created above references one of those scripts to operate, in particular getRecordFromFormWithKey, which scans for records that have a particular value and returns the first one it finds. This is how I map the ID’s back to make the links work.

    February 7, 2022 at 2:33 PM #46634

    Stig Widell
    Participant

    OK Sam,
    I imported the Script in your ScriptManager …tfarc into the document Djur successfully (I hope)
    and I copied and pasted your Kalva into Scripts in the form Rekryteringsdjur also successfully (I hope) but I havent tried it yet (too late in the evening). How do I start an entry of a new calf, with a new calf record or with an identified mother record? You discussed both alternatives above.

    February 7, 2022 at 6:36 PM #46640

    Sam Moffatt
    Participant

    I had assumed that Rekryteringsdjur was the mother record though my grip of Swedish is limited to ‘Hej’ so you start there with the mother record and it should create a Kalvingar record linked to the Rekryteringsdjur and the Avelstjur listed.

    February 8, 2022 at 1:07 AM #46646

    Stig Widell
    Participant

    When I test now the following happens:
    -click on a cow in form Rekryteringsdjur and the “Avelstjur” (pedigree bull) i shown correctly
    -click on “Kalvningar” under heading Reproduktion and switch to form Kalvningar is made
    -click on + for a new calf record and the mother ID is-shown but not father-ID. In the calf record is shown “No”
    What did I do wrong?

    February 8, 2022 at 1:39 AM #46649

    Sam Moffatt
    Participant

    So in the Rekryteringsdjur record, you need to create a new form script called “Kalva” and then run that form script for it to create and link the records together because the script does validation that not only you set the bull but also that the bull with that ID exists if that makes sense.

    February 8, 2022 at 4:14 AM #46653

    Stig Widell
    Participant

    Ok I entered the ”Kalva” in the Script in form Rekryteringsdjur but I didnt run it. Now when I did I got enclosed error

    Attachments:
    You must be logged in to view attached files.
    February 8, 2022 at 12:11 PM #46657

    Stig Widell
    Participant

    Sam, I send you the template again.

    Attachments:
    You must be logged in to view attached files.
    February 8, 2022 at 2:07 PM #46659

    Stig Widell
    Participant

    Can you make the Avelstjur ID in decimal style with one decimal place?

    February 8, 2022 at 11:34 PM #46663

    Sam Moffatt
    Participant

    It looks like it’s working? I imported your template over my existing database. Make sure on iOS you are in the record before using the script editor or running the script but I did a quick test and it seemed to work for me.

    Attachments:
    You must be logged in to view attached files.
    February 9, 2022 at 1:12 AM #46665

    Stig Widell
    Participant

    What do you medan with:
    Make sure on iOS you are in the record before using the
    script editor or running the script?
    I made the run of script in IOS

    February 9, 2022 at 11:30 AM #46667

    Sam Moffatt
    Participant

    So on iOS, you can get to the script editor and run script from the list of record but you need to tap into a record to select it before running the script if that makes sense. When you’re in the list view, you usually get the error that record is not defined because you’re not in a record.

    February 9, 2022 at 11:49 AM #46668

    Stig Widell
    Participant

    Thank you so much Sam. It works perfectly now in both mac and IOS.
    I migrated FROM mac to IOS to get rid of the problem in IOS.
    The Fader-ID in the calfs record is displayed correctly ie 7973,0
    But in the Mother record “Avelstjur” (pedigree bull) is displayed 7973 (without decimal).There it is a text field so is it possible to get it right?

    February 9, 2022 at 7:30 PM #46669

    Sam Moffatt
    Participant

    You can just change the type from text to number and do the formatting. It will warn you but text to number, assuming all of your data are numbers, should be safe. It shouldn’t break things but once everything is unified it should work.

    February 11, 2022 at 12:32 PM #46689

    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?

    February 11, 2022 at 1:05 PM #46691

    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.

    February 11, 2022 at 1:26 PM #46692

    Stig Widell
    Participant

    No field-ID are identical
    Enclose template

    Attachments:
    You must be logged in to view attached files.
    February 11, 2022 at 2:48 PM #46696

    Stig Widell
    Participant

    Confusing message the previous one I sent. I meant that all field-IDs seem to be correct.

    February 11, 2022 at 3:15 PM #46697

    Stig Widell
    Participant

    and I have tried all evening to change font size in date fields with no success

    February 11, 2022 at 11:20 PM #46698

    Sam Moffatt
    Participant

    So I loaded up that template and didn’t have any issues, it seemed to work for me. Perhaps a screenshot of your record showing the Avelstjur field?

    Can you be a little more specific about the font size?

    February 12, 2022 at 12:07 AM #46699

    Stig Widell
    Participant

    I sent it via my cell and Brendan answered about the font

    Attachments:
    You must be logged in to view attached files.
    February 12, 2022 at 12:12 AM #46701

    Stig Widell
    Participant

    It worked initially so something must have been changed

    February 12, 2022 at 1:27 AM #46702

    Stig Widell
    Participant

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

    February 12, 2022 at 9:55 AM #46703

    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.

    February 12, 2022 at 12:03 PM #46705

    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.

    February 12, 2022 at 12:47 PM #46706

    Sam Moffatt
    Participant

    The challenge with automating that is that you don’t have any limits in place to ensure that there is a unique constraints. Nothing prevents two (or more) bulls being assigned to the same grupp field because it’s just pick lists. You would need to restructure to instead of using pick lists have Link to Form fields and a new Grupp form that could be used to store the links out to the bull which Tap Forms should attempt to enforce consistency of only one bull to a single grupp but even then it’s sometimes a little weird.

    February 12, 2022 at 1:05 PM #46707

    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?

    February 12, 2022 at 1:10 PM #46708

    Stig Widell
    Participant

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

    February 12, 2022 at 1:12 PM #46709

    Stig Widell
    Participant

    …and it worked that way initially

    February 12, 2022 at 1:20 PM #46710

    Stig Widell
    Participant

    As each bull in form Avelstjurar has its unique grupp there will never be two or more bulls in the same grupp

    February 12, 2022 at 1:24 PM #46711

    Stig Widell
    Participant

    It worked fine the first day but the something happened so the bull couldnt be identified

    February 12, 2022 at 1:56 PM #46712

    Stig Widell
    Participant

    I think the way you created Kalva is super. The question is why doesnt it work at the moment?

    February 12, 2022 at 2:57 PM #46714

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

    February 12, 2022 at 5:32 PM #46715

    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.

    February 12, 2022 at 11:30 PM #46717

    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?

    February 13, 2022 at 1:55 AM #46719

    Stig Widell
    Participant

    OK, You are the expert. Hereby I initiate a new structure.
    I enclose a new template with a new form Grupper. Please help me out with the rest (the different links), I do not know what you mean with “form field 1:M”

    Attachments:
    You must be logged in to view attached files.
    February 15, 2022 at 12:03 AM #46751

    Stig Widell
    Participant

    This part I dont know to create:
    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.

    February 21, 2022 at 12:21 AM #46804

    Sam Moffatt
    Participant

    Ok, so minor change to Kalva to change how keyValue is determined once you have field links:

    	//let keyValue = record.getFieldValue('fld-db52d7055ddd40cf95f50bcf8e2fff3d'); // ID of the Avelstjur field in Rekryteringsdjur form.
    	
    	var grupp_id = 'fld-f195db7abf3145f08eeb26dbb610bce1'; // ID of the grupp link from form fieldType
    	var avelstjurar_djur_id_id = 'fld-5529d9d293934026a0b746890c2baf32'; // ID of the field from Grupp
    	
    	let gruppRecord = record.getFieldValue(grupp_id);
    	
    	if (!gruppRecord) {
    		Utils.alertWithMessage("Fel!", "Sätta grupprekordet");
    		return;
    	}
    
    	keyValue = gruppRecord.getFieldValue(avelstjurar_djur_id_id);
    

    The ID’s should match everything from the attached template. It adds a Grupp form, you’ll need to create a record for each of the grupp’s you’ve got (I did a quick copy paste from the pick list, I’m sure you can just type it directly) and then in the grupp link the correct avelstjurar for them. That should then create a single value chain from rekryteringsdjur up to grupp to avelstjurar. There is an extra calc field to add in the djur ID and prefix when you select the grupp.

    When you import, there should be two scripts, I modified the one that was favourited. The script should be updated for the above and should work properly.

    Attachments:
    You must be logged in to view attached files.
    February 21, 2022 at 12:47 PM #46815

    Stig Widell
    Participant

    Sam, I thought you left the thread, but you didnt lucky me!
    I tried to import Grupp.tff but got the error enclosed.

    Attachments:
    You must be logged in to view attached files.
    February 21, 2022 at 1:26 PM #46817

    Stig Widell
    Participant

    I have worked a bit further with the document since we last wrote.
    I dont know if anything there will interfere with your amendments
    See attachment

    Attachments:
    You must be logged in to view attached files.
    February 21, 2022 at 4:31 PM #46822

    Sam Moffatt
    Participant

    You’ll need to import it back into your doc via File -> Import -> Form Template. It should apply relatively cleanly though it might add back any field you deleted or rollback any minor changes to the field configuration.

    The start of the year is review season, usually eats up a bunch of dedicated concentration time to write up documentation.

    February 22, 2022 at 1:39 PM #46828

    Stig Widell
    Participant

    So sorry Sam but I cant import your Grupp.tff
    I do as you say
    I am so eager to import it but Tap forms says it is not imported (see enclosed)

    Attachments:
    You must be logged in to view attached files.
    February 23, 2022 at 12:34 AM #46834

    Sam Moffatt
    Participant

    That’s certainly odd, I just tried it myself and it gave me a similar error even with a clean copy. This might be something for Brendan to look into though.

    February 23, 2022 at 2:30 AM #46848

    Brendan
    Keymaster

    Hmm… it worked for me. I was able to import it.

    Attachments:
    You must be logged in to view attached files.
    February 23, 2022 at 2:31 AM #46850

    Brendan
    Keymaster

    And into a brand new document.

    Attachments:
    You must be logged in to view attached files.
    February 23, 2022 at 12:09 PM #46857

    Brendan
    Keymaster

    Oh… oops. I had imported the file that Stig attached a couple posts above and that worked fine.

    I just tried the Grupp.tff file and ya, it didn’t work.

    But the strange thing is when I tested it in Tap Forms running in Xcode in the debugger, the command to unarchive the file returned nil.

    Can you try exporting the file again Sam?

    Or try an archive export instead of a .tff export.

    February 23, 2022 at 12:26 PM #46858

    Sam Moffatt
    Participant

    Curious, here’s a zip’d copy of the document I’m currently working with and able to repro the error using TF build 2242.

    Attachments:
    You must be logged in to view attached files.
    February 23, 2022 at 7:05 PM #46866

    Brendan
    Keymaster

    It worked fine for me exporting from that document and then importing the .tff into a new document.

    I used build 2243 though.

    Try the latest build. Although not sure why that would make a difference. I never changed anything with the export .tff code.

    The problem seemed to be that the .tff file had references to TFField objects where it shouldn’t. I encode a field into a dictionary before it’s archived, so there should never be actual Tap Forms entity references in it. When my code attempted to unarchive it, it saw the TFField in it so didn’t unarchive it and so it couldn’t re-build the form and fields.

    February 23, 2022 at 11:27 PM #46869

    Stig Widell
    Participant

    I successfully imported the TheStig document. But that of course is without all my data.
    So what will be the next step for me?

    February 24, 2022 at 2:15 AM #46870

    Brendan
    Keymaster

    Export the form template and import it into your main document. If you still get the same error, try exporting the Tap Forms Archive file instead and import that into your main document.

    February 24, 2022 at 2:34 PM #46875

    Stig Widell
    Participant

    Japp, I did as Brendan wrote and it worked. Everything looks just fine. Marvelous job you have done Sam. I am so grateful.
    The two “Kalva” scripts should both be there? I ticked the first one.
    Enclosed please find two print screens with questions.

    Attachments:
    You must be logged in to view attached files.
    February 24, 2022 at 5:54 PM #46878

    Sam Moffatt
    Participant

    One has the latest changes in it, one I think will be out of date. Just nuke the script that doesn’t have the changes I noted above.

    February 27, 2022 at 1:14 PM #46890

    Stig Widell
    Participant

    Sam, I regard the Kalva-script as a big success.
    Thank you very much for your help.
    As I indicated in this thread on 12 feb there is a need for one further final script in the document Djur.
    If you have time and still got inspiration I would ask you to help me with that one as well.
    This thread is too long so I intend to start a new one for that script.

    March 21, 2022 at 1:08 PM #47020

    Stig Widell
    Participant

    Hi again,
    The script Kalva, created by Sam Moffatt, worked very well a couple of weeks ago.
    Now when I have to use it because calves are started coming the calfs father in the form Kalvningar is not shown.
    I get “Script is run complete” instead of “Gjord”
    Enclose template.
    Sorry about this.
    Stig

    Attachments:
    You must be logged in to view attached files.
    March 21, 2022 at 1:17 PM #47022

    Stig Widell
    Participant

    The message “Script is run complete” I received in IOS.
    When running in Mac I received “Fel! Sätta grupprekordet”

    March 21, 2022 at 10:29 PM #47026

    Sam Moffatt
    Participant

    iOS is a little weird with the async dialogs at times, it’s almost parity but sometimes things don’t end up identical.

    March 22, 2022 at 8:10 AM #47027

    Stig Widell
    Participant

    Sam The problem is not the non parity.
    The problem is that fader-ID is not shown after running the script Kalva.

    March 22, 2022 at 11:24 AM #47028

    Stig Widell
    Participant

    Template sent 1:08 PM above

    March 23, 2022 at 4:12 AM #47030

    Stig Widell
    Participant

    Sam again,
    After having explored a bit further, this is the situation:
    The script Kalva works fine with 2 of the breeding bulls (1 & 4)
    It doesnt work with 3 (the rest) of the breeding bulls (1, 3 & 5)
    I then get the message in MAC “Varning Det gick inte att hitta posten!”
    I cant figure out why some bulls work and not the others.

    March 24, 2022 at 12:57 PM #47034

    Stig Widell
    Participant

    Instead of mentioning “breeding bulls” above I should have written “Grupp”. Grupp 1 and 4 works fine the others not. When I add a new grupp and a new breeding bull it doesnt work either.
    I have put in hours in this so I really need some more help, please!

    March 25, 2022 at 2:02 AM #47037

    Stig Widell
    Participant

    When I duplicate the Grupp record that works, the copy doesnt work!!!

Viewing 70 reply threads

You must be logged in to reply to this topic.