Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

Creating a New Record In a Relationship


This topic is 7640 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Ok I have a odd question but can you create a record through a relationship without using portals?

Heres my problem... I have 1 portal that just shows a list of current records that are related... then I have 7 global fields that are filled in by user then a script does a check on it when you hit save and then copys the data to the portal.

This works 100% with no problem but I hate having to the portal show a new record line at the end everytime..

So what I did to fix this is to create 2 relationsships one for the portal(viewing no create) and one for saving.. The one for viewing doesnt show the empty line at all which is perfect..

The one for saving im haveing problems with.. It seems I can only create a new related record through another portal only (Using the go to portal row Last and then go to portal row next way).

Is there another way to create a new record without using portals through a relationship?

PS I tryied making a invisiable portal with 1 field and this worked perfect using the (Go to Field - Go to Last Row - Go To Next) but the problem is if the invisbale portal is clicked then it highlights...

Posted

nm figured it out hehe

Dont know why this works but all I do is use a script to go to related record and then go a Globalfield to RelatedField and it works... ( I dont understand how its making a new record rather than writing over it but it works liek I want it to smile.gif )

Posted

I guess you could flip to the layout with the "allow creation of related records." But there is a limitation, in that it will fail when you run out of rows.

I seldom use "allow creation." I just call a script in the file where I want the new record. First I set the parent ID into a global.

You also need Constant=1 calculation fields in each file, and a constant relationship from the child to the parent (though in reality any relationship can get a global).

Scripts (psuedo):

Freeze Window

Check Globals

Set Field [ ParentID global, ParentID ]

Perform Script [External, "Child"]

[The script called in the child file]

New Record

Set Field [ ParentID, Parent_Constant::ParentID global ]

Set Field [ Field1, Parent_Constant::Field1 global ]

Set Field [ Field2, Parent_Constant::Field2 global ]

etc.

Exit Record

[A single step in the Parent file will return you.]

Exit Record

Posted

AvrioTech said:Ok I have a odd question but can you create a record through a relationship without using portals?

Yes.

1. Do NOT turn on "allow creation of related records" in the definition of the record-viewing portal.

2. Define a global field "gItemRecID".

3. Create a relation to the item file where gItemRecID = the auto-generated record ID field in the item file. Set this relation to allow creation of related records. Call the relation "Selected_Item".

4. Your new record script should do this:

set field [gRecordID, textToNum("")

exit record/request

#auto-create item record

set field [selected_Item::FirstName, gFirstName]

set field [selected_Item::LastName, gLastName]

set field [selected_Item::Address, gAddress]

etc.

#deselect item record

set field [gRecordID, textToNum("")

Posted

Is there a difference between using a Global Field or Calculation as a relationship between the two files?

(basicaly in a large multiuser enviroment will it make a difference)

because right now im using a calculation field with a constant of 1 on both files and relating them that way and its working fine (single user but I havent tested it mutliuser)

Posted

Then you didn't follow the directions at step 3. Post a description of what you actually did.

Posted

Your suggestion is just a more complicated and maintenance intensive version of the method I posted. If you don't want to use the actual auto-create record ID as the link field, then use a global on the left side and your temp field on the right. Put a unique value into the global like status(CurrentDate) & " " status(CurrentTime) & " " & random * 1000. Then you don't have to do the maintenance of cleaning out the temp key on the right side.

Posted

AvrioTech said:

Is there a difference between using a Global Field or Calculation as a relationship between the two files? (basicaly in a large multiuser enviroment will it make a difference)

because right now im using a calculation field with a constant of 1 on both files and relating them that way and its working fine (single user but I havent tested it mutliuser)

The performance is pretty much strictly dependent on the number of records in the relationship. The constant approach is the worst-perfomance approach. It passes ALL record IDs across the network. As your data set grows, this can lead to problems. Depends on record count and and your network.
Posted

Queue ...

Whaddayaknow! I vaguely recalled that it was either you or Bob W., but definitely remembered it was one of the gurus somewhere smile.gif And I'm still grateful to you for passing it on to me. Re-reading the original thread also reminded me of the multi-user issues involved, so thanks for that as well.

This topic is 7640 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.