Solved

Best method to transfer data from one database to another within the inbuilt scripting environment.

Posted on 2003-10-31
4
746 Views
Last Modified: 2010-04-27
What is the best method to transfer data from fields in one related database to fields in another only using the inbuilt scripting.

I am creating a school database and have to transport values from a database called "behaviour level report" to a related database called "welfare record".

It is easy enough to transfer values between layouts using the copy, paste functions etc. however. the ability for one database to issue  commands in an external database (related) appeares to be limited to basic functions such as  "open file welfare record". From that point on you loose controle.  I can't then copy specific field values into fields in this external database.
0
Comment
Question by:naubrey
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Mariano_Peterson earned 250 total points
ID: 9660454
This is from a previous post of mine at another list:
----------

There are several ways of doing this. I'll describe the method I use:

This exampe assumes you have three files:
Main.fp5
Parent.fp5
Child.fp5

Main.fp5 should have the following fields:

zkg_newID (global number)


Parent.fp5 should have the following fields:

zkp (primary key, number, auto-enter serial)
zkg_newID (global number)
field1 (any data field)


Child.fp5 should have the following fields:

zkp (primary key, number, auto-enter serial)
zkf_parentID (number, foreign key to parent table)
field1 (any data field)


Parent.fp5 should have the following relationship:

Relationship Name: Main.Constant_NOT
Related file: Main.fp5
Left field: zkg_newID
Rigth field: zkg_newID
** When you create this relationship, you'll get an alert warning you that this relationship will not work. This is OK.

Relationship Name: Child.New
Related file: Child.fp5
Left field: zkg_newID
Right field: zkp


Child.fp5 should have the following relationship:

Relationship Name: Main.Constant_NOT
Related file: Main.fp5
Left field: zkg_newID
Right field: zkg_newID
** When you create this relationship, you'll get an alert warning you that this relationship will not work. This is OK.


Child.fp5 should have the following script:
Script Name: "NewRec (external)"
Script Steps:
Allow user abort [Off]
Set Error Capture [On]
Enter Browse Mode []
New Record/Request
Set Field [Parent.constant_NOT::zkg_newID, "zkp"]

---

Now that you've created an infrastructure, we can create related records and set values in them easily.

From Parent.fp5, lets create a script, "CreateChild":
Script Name: "CreateChild"
Script steps:
Allow user abort [Off]
Set Error Capture [On]
Enter Browse Mode []
#
# Create a child record and get a pointer to it
Perfom Script [Sub-scripts, External: "Child.fp5", "NewRec (External)"]
Set Field ["zkg_newID", "Menu.Constant_NOT::zkg_newID"]
Exit Record/Request
#
# Set attributes for the new child record:
Set Field ["Child.New::zkf_parentID", "zkp"]
Set Field ["Child.New::field1", "field1"]
Set Field ["Child.New::field2", ""any data here""]
Set Field ["Child.New::field3", "field3"]
... etc ...


---


This methodology is convenient because it allows you to easily set as many fields as you like in the child file -- and the changes are limited to a single script. Also, by avoiding the use of copy/paste or setting globals in script and then reading them in another, you make the code more compact, less error-prone, and easier to debug.

As long as you're careful to maintain the infrastructure by including the "zkg_newID" field, the "NewRec (external)" script, and the "Main.Constant_NOT" relationship in every file, you can easily create a record in any file at any time without having to add fields, scripts, or relationships.

Hope this helps!

0
 

Author Comment

by:naubrey
ID: 9669524
Thanks for your reply
Apologies for the time. I was waiting for some more answers as your answer didn't quite fit my solution and I had to work it through.

Probably not the best solution however:
I ended up getting my result by

setting the value of fields to a global fields.

Using the  "external script function" to paste in the values into the related fields.
0
 
LVL 3

Expert Comment

by:Mariano_Peterson
ID: 9673228
Avoid pasting; it does not offer consistent behavior and is highly error prone.  It is considered extremely bad programming practice to use copy/paste.  Instead, use the set field script step.

Using global fields works fine, but creates the unnecessary overhead and inconvenience of having to add new global fields every time you want to transfer an extra value.

Good luck,
Mariano
0
 

Author Comment

by:naubrey
ID: 9674908
Apologies for my use of the word paste. I am using the set function.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FM - Tracking Changes from an Update Import 3 378
Taking database online 3 305
FM Exporting Pictures In Container 1 983
send mail from Filemaker Pro 10 4 93
Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now