July 21, 200322 yr Question from another forum "Does anyone have any example of a button from one database that will go to the same record in another database with the same ID. But I need it to first search all the records in the second database so that if there are multiple records with that ID it will show them.. if not then create a new record and set the ID field to what the ID field is in the first database. I have tried 100 different ways and can't get it to work correctly. Thanks," See attached screen shots ScreenShot for Find or Add Script.zip
July 21, 200322 yr Hi Robert, You could set your button in your first database to copy the ID from the field then perform external script in DB 2 lets call it Find_Or_Create The Find_Or_Create Script would go something like this Enter Find Mode [] Paste [select, "YourIDField"] Perform Find [Replace Found Set] If ["Status( CurrentFoundCount) > 0"] Go to Layout [LayoutDisplayingSearchResults] Else New Record/Request Paste [select, "YourIDField"] End If This should work but I have not tested it so may need tweaking slightly. The only problem I can forsee is when no records are found it will show the relevant message, you would have to click to continue for the new record to be created. You could proably get around this though by adding a step - if Status(CurrentError) = 401 then do something. Hope this helps Ed.
July 21, 200322 yr OK, so I didn't look at the screen prints before I replied! Looks a bit more complicated than this. I will actually look at the attachments now! Ed.
July 21, 200322 yr I'd go with a relationship here from file A to file B.... Main Script. If (IsValid::your relationship) Go to Layout with Portal Else SetField(g_NewID, ID) Perform External script Refresh External Script SetField (g_ID, :Constant:g_NewID) New Record SetField (ID, g_ID)
July 21, 200322 yr Author Right Ugo I agree , but I had an old file that I did in in and it was eaaier just to take screens. Lazy I guess.
July 21, 200322 yr Robert, Are you saying the quotes were from another user on another Forum and this was your answer ? Sorry about that then. At least I'm not worried anymore... Hmm.. If that member was a man, I'm OK with this. If it was a girl, you're not a GentleMan What a Pain with Find mode this seems to me... At least it works perfectly I assume
July 22, 200322 yr I had no doubt Chopper. Replace "At least it works perfectly I assume" with "I have no doubt it works perfectly" (Labguage barriers...). I was concerned and worried YOU'd asked for help on this one. Glad you weren't in trouble
July 26, 200322 yr I've attached a small example solution for this that basically uses the IsValid(ID | File2_ID::Constant) test. From there you branch to either displaying matching records, or creating a new related record. It's really easy to set up this kind of scripted process without having to perform any finds. If you have any questions about the example files, email me Match_or_Create.zip
July 26, 200322 yr Is this sample done with FM 6.0 ? I can't get it to work on 5.5 as there are some steps missing in the script. But Yes, from what you're describing, either IsValid or not IsEmpty would be easier. As Robert already pointed though, he just was lazy....
July 26, 200322 yr Ugo ... Yes, sorry, it's in FM6. I don't even think to develop in 5.5 anymore. I'd send you a runtime version, but if you wanted to examine the scripts, you'd still be limited by 5.5.
Create an account or sign in to comment