Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
September 28, 2023 at 1:33 PM #49936
In reply to: Convert 2 fields
Brendan
KeymasterThere’s two places for scripts. Either a Script Field, or a Form Script. Both have their uses.
Script fields will get triggered to run whenever a value that the script field references is modified. Form scripts require you to manually run them.
Each have their uses. If you want something to happen whenever you change a value, use a Script Field. You don’t have to even display it as you can hide it. it will work silently behind the scenes.
If you had some sort of bulk process you’d like to do on all your records that you want to run manually, then use a Form Script.
September 28, 2023 at 12:37 AM #49930In reply to: Convert 2 fields
Michael Tucker
ParticipantYou can do it without scripts, I’ve attached a sample file.
Attachments:
You must be logged in to view attached files.September 26, 2023 at 6:12 PM #49924In reply to: Current Location via JavaScript?
Brendan
KeymasterHi Pinny,
I’m sorry, but I don’t have an API in Tap Forms to get the current location via JavaScript. I’ll see about adding one.
Thanks,
Brendan
September 26, 2023 at 3:09 AM #49918Brian Lennon
ParticipantI have one more question, hopefully a straight-forward one and best illustrated by the accompanying screen grab.
Field TRAININGold links to a form called TRAINING and contains the old data. The TRAINEEid is the reference code for this person in the PERSONS form that holds these fields.
Field TRAININGnew links to COURSES and is the intended destination of the new records. I have manually inserted a record using the tick at the bottom and selecting course coded 38 from the COURSES form. This is the action I want to script to complete data import and restructuring.
The question: If TRAININGnew links to courses as a join and sharing a common code, where is the common code in TRAININGnew? In TRAININGold, the TRAINEEid (137905) linked to TRAINcode 38, 62 and 78.
When I use the tick to show course 38 in TRAININGnew, it is obviously linking in some way to the TRAINEEid of 137905 but this shared link code is not visible in the linked table at TRAININGnew. Somehow I reckon I need to incorporate this invisible link into my script that attempts to replicate the tick action.
Once I have all the TRAININGold records transferred to TRAININGnew, my intention is to add new course records using the tick approach.
Thanks again
Attachments:
You must be logged in to view attached files.September 25, 2023 at 9:28 AM #49915Brian Lennon
ParticipantMany thanks Brendan – you capture exactly what I’m trying to do. I will follow your suggestions. I need to tune in more to the conventions of Javascript.
Great support!
Brian
September 24, 2023 at 12:38 PM #49912Brian Lennon
ParticipantBrendan – I feel I am presenting an issue that would probably use up too much of your precious time.
I’m still struggling with the syntax of javascript and am probably trying something that’s too far beyond my present capabilities though I did have success with some simpler scripts. (I feel like someone who has just started to learn English and is seeking help with an understanding of the grammar of Joyce’s Ulysses!)
Anyway, will attach the form template as requested.
My original database used 1:1 links from PEOPLE to TRAININGold (that just carried the person’s code and the course code) and this in turned linked to COURSES via the course code. I’m aiming to simplify this so that PEOPLE links directly to COURSES. With over 4,800 records in the database, a script is the only sensible way to process this import.
I’m not sure how much the template communicates so here are the current linkages:
Form PEOPLE > Field TRAININGold >>link 1:1 >> Form oldTRAINING (original data here)
Form PEOPLE>Field TRAININGnew>>link many:many>>form COURSES (wanting structure to use this link)
In the script I sent earlier I had changed the names of some variables to make them more understandable to myself and perhaps that was not the right thing to do.
If you can give me a few pointes in the right direction I’ll struggle on in my learning process.
Many thanks for your support.
Attachments:
You must be logged in to view attached files.September 24, 2023 at 11:17 AM #49911Brendan
KeymasterHi Brian,
So there are many issues with your code.
- This syntax is incorrect unless you actually have a form named
newTrainingId.var newLinkedForm=document.getFormNamed('newTraining_id');
- You weren’t using the variable
newLinkedFormanyway in the rest of your code. - The line
record.setFieldValue(newCode_id, oldTraining_code);is just setting the value on the same parent record over and over again.
It would help me to better understand what you’re wanting to do if you posted your form template so that I can look at your form structure and see if I can help you with the script.
September 24, 2023 at 6:59 AM #49909Brian Lennon
ParticipantBrendan – I tried to build in your suggestions but no luck so far. In fact, getting the different entries in the old record worked fine. Popping these into the new link doesn’t seem to work. Remember, I’m practically a total novice with Javascript so I’m probably committing massive mistakes. Here’s what I’ve tried so far with comments that hopefully give a clue as to what I’m trying to do. Any suggestions will be welcome but I acknowledge this may be a big job so don’t worry if you don’t have time.
//PURPOSE: restructuring imported data from earlier utility //to relocate a training course code to a different linked form //Getting list of existing training course codes for each person //from the old TRAINING linked form 1:1 function recordsLoop() { var oldTrainingForm_id = 'fld-732ad9dbc05249feac197450c84ef299';//incoming linked form var oldTraining_code_id = 'fld-f8bb7875bd094c4c94ea0ae98c5536d8';//course code id var oldTrainingValue = record.getFieldValue(oldTrainingForm_id); //var oldCodelist = [];//array to store incoming codes //new link (to COURSES form) to receive the code and so link to COURSES //the new training form is linked many:many var newTraining_id = 'fld-ac031e652f864a4a8ad98d20efb7f360'; var newLinkedForm=document.getFormNamed('newTraining_id');//not sure about this! var newCode_id = 'fld-549ed54657f94e81a9f1a3f0c4bff844';//field to receive incoming code for (var index = 0, count = oldTrainingValue.length; index < count; index++){//looping through incoming linked form var oldTraining_code = oldTrainingValue[index].getFieldValue(oldTraining_code_id);//get value of each incoming code if (oldTraining_code) {//if there is a code // read each course code from old TRAINING form console.log (oldTraining_code);//getting the right incoming codes here! They appear as a list in console //the bit that's not working //attempting to add the oldTrainging_code to the TRAININGnew link to form COURSES //My attempt to program what can be done manually by clicking the tick ("Select existing linked records") below the TRAININGnew table. //console.log("ACTION "+ oldTraining_code_id + "--" +newCode_id); //this looks like it does what I want ... but it does nothing! record.setFieldValue(newCode_id, oldTraining_code); } } return; } recordsLoop(); document.saveAllChanges();-
This reply was modified 2 years, 4 months ago by
Brendan. Reason: edited to add back ticks around the code
September 21, 2023 at 4:49 AM #49901In reply to: Custom join condition
Mary Stamper
ParticipantThanks. I’ll think about this one. Just started using scripting. I’ll try to figure it out.
September 21, 2023 at 4:46 AM #49899In reply to: “where” clause on table-derived pick list
Mary Stamper
Participantha ha, not surprising. I tend to think more generally…..I have a data base of vocabulary words. Just 1 table. I choose a general part of speech (verb, noun, adjective, etc) and then one or more subtypes which are dependent upon the part of speech. For a verb, that could be transitive, intransitive, reflexive and a few more. So it is a dependent picklist. Not sure if scripting could be used to populate the dependent picklist based upon the value in the part-of-speech field. I’m relatively new to Tapforms, and I must say that I’m impressed with what you’ve accomplished. I’m not new to databases however, been doing Oracle for 30 years on my jobs.
-
This reply was modified 2 years, 4 months ago by
Mary Stamper.
September 21, 2023 at 12:34 AM #49897Brian Lennon
ParticipantMany thanks Brendan – I will try your solution. It will take me some time to absorb Javascript’s way of working!
September 20, 2023 at 11:26 PM #49895In reply to: Custom join condition
Brendan
KeymasterJoin type relationships can only do a direct equals comparison and not a contains type comparison. But you can use a Script or Calculation field to return some value in both form F1 and F2 that would do the special function to get an appropriate value (such as
matched) and then use the Join from and to fields to join with those fields in each form.September 20, 2023 at 11:20 PM #49894In reply to: “where” clause on table-derived pick list
Brendan
KeymasterAlso, hope you don’t mind, but I moved this thread to the Using Tap Forms forum instead of the Script Talk forum where you posted it. It’s not about the scripting feature.
September 20, 2023 at 9:17 AM #49886In reply to: Script to copy records from one form to another
Glen Forister
ParticipantI’ve been looking for a Script like this that doesn’t need modification to work in any database and copy records from one to another. I hope any bugs that exist get worked out. I’m not a scripter so wouldn’t be able to modify it to work in my environment.
Thanks guys.
September 20, 2023 at 9:10 AM #49885In reply to: Convert 2 fields
Glen Forister
ParticipantYes, I would like to do that. I’m wondering though why create a new field to house the script instead of putting the script in the list of Scripts in the Scripts Tab. Just a curious question.
But, the Sctipt would be completely different that the above, so can you give me what I need. Sorry I can’t do it and with the above, I’ve proven that the ChatGPT version isn’t great if you don’t already know Scripting and can debug it.
Thanks.
- This syntax is incorrect unless you actually have a form named
-
AuthorSearch Results