If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > FileMaker > Creating a new Record in a Different Database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-19-05, 16:30
chevell chevell is offline
Registered User
 
Join Date: Sep 2003
Posts: 7
Angry Creating a new Record in a Different Database

I could swear I've done this before, but for some reason its not working. I want a script to create a new record in a different database from data in a current database record. I thought You just used "set field" or insert calculated value and it automatically created a new record with that data in the target field. For whatever reason its not working.

I am running FM Server 7 Advanced and FMP 7 Developer. I'm having trouble updating the files even though they are both open on the Developer machine.

Ideas? Thanks!
--
Chevell
Reply With Quote
  #2 (permalink)  
Old 10-20-05, 19:38
<Ender> <Ender> is offline
Registered User
 
Join Date: Aug 2005
Location: Minneapolis, MN
Posts: 56
You can create a related record with a Set Field[] as long as the relationship is defined to 'Allow creation of records in this table via this relationship'. However, this will only create one record in the related table, and only if there's no related record already.

If you wish to create more than one record on the many side of a one-to-many via a Set Field[], you'll need to use a filtered relationship. By changing the filter on the parent side to one that results in no related records, you can then add a new record via that Set Field[].

For example, you could use a relationship that includes the parent key, along with the 'Type' of the child record. Then by changing the Type, you can create a related record for each Type:

Parent <=> Child =
Parent::ParentID = Child::ParentID
AND Parent::gType = Child::Type

This works great if you only need one Child record for each Type.

For the case where you want to be able to create as many related records as needed (not tied to a specific Type,) you could use a script to first set a key (global text field) on the parent side that's based on a random number. Something like:

Set Field [ gRandomKey ; GetAsNumber(Get(CurrentTimeStamp)) & "-" & Random * 10000 ]

On the child side, the matching key would be a regular text field and would have no meaning other than for creating records through this relationship. The relationship would be:

Parent <=> Child =
Parent::ParentID = Child::ParentID
AND Parent::gRandomKey = Child::CreateKey

Of course, it may be simpler to just navigate to a layout based on the Child table, perform a New Record script step, then populate the foreign key and any fields you wish.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On