AvrioTech Posted February 28, 2004 Posted February 28, 2004 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...
AvrioTech Posted February 28, 2004 Author Posted February 28, 2004 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 )
Fenton Posted February 28, 2004 Posted February 28, 2004 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
bruceR Posted February 28, 2004 Posted February 28, 2004 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("")
AvrioTech Posted February 28, 2004 Author Posted February 28, 2004 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)
AvrioTech Posted February 28, 2004 Author Posted February 28, 2004 BruceR I tried what you said and got this response The relationship "MakeNew" is not valid and must be corrected before this field can be modified.
bruceR Posted February 29, 2004 Posted February 29, 2004 Then you didn't follow the directions at step 3. Post a description of what you actually did.
Jim McKee Posted February 29, 2004 Posted February 29, 2004 A clever way to create related records that does not require a sub-script in the Child file is one that I learned last year from one of the gurus on FileMaker Caf
bruceR Posted February 29, 2004 Posted February 29, 2004 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.
Ugo DI LUCA Posted February 29, 2004 Posted February 29, 2004 Also have a look at this thread as it is related and Helpful Harry attached a cool way, that also provides to create records from the "first" row of a portal. You'd see why first is within quotes.
-Queue- Posted March 2, 2004 Posted March 2, 2004 Hi Jim, I think you might have actually learned it from me here on this forum
bruceR Posted March 2, 2004 Posted March 2, 2004 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.
Jim McKee Posted March 2, 2004 Posted March 2, 2004 Queue ... Whaddayaknow! I vaguely recalled that it was either you or Bob W., but definitely remembered it was one of the gurus somewhere 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.
Recommended Posts
This topic is 7917 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 accountSign in
Already have an account? Sign in here.
Sign In Now