goral Posted April 9, 2003 Share Posted April 9, 2003 I have a question about linking related files. Example: DB1 has primary key ID#,DB2 has primary key LINE#. DB1 and DB2 are related by the DB's ID#. When I'm in DB1 I create record in DB2 by running a script which opens DB2, creates new record and copies ID# in DB1 and paste it in ID# field in DB2. Then i can display related records in Portal in DB!. The problem is if I want to duplicate DB1 record, it will not duplicate related DB2 records. Is there any other way of doing it? How can I copy primary key from one DB to another. I read many posts on this forum and I can't find any answers. Please help!! Link to comment Share on other sites More sharing options...
danjacoby Posted April 9, 2003 Share Posted April 9, 2003 Huh? What the heck is LINE#? If you're using an ID# field in DB2, that's your key field for this relationship. Never mind. The point of a relationship is that you don't have to duplicate anything (and why would you, anyway -- isn't each record supposed to be a unique individual?). Nor do you need scripts to create records in the related file. Create a portal in DB1 and create the new records (in DB2, but related to the specific record in DB1) by entering data in a new line in the portal. My guess (and it's just a guess) is that you have a record in DB1 with a set of related records in DB2. You want to create a new record in DB1, along with a concomitant set of related records. To do this, you need to create the new record in DB1, then copy the ID# -- or better yet, send it to a global field -- then perform a script in DB2 that duplicates the record set, replacing the "key field" with the contents of the global field in DB1. The trick here is duplicating the set of related records. Finding them is easy -- from the old record in DB1, the script step is "Go to related record (Show related only)", or something close to that. The problem is, how do you duplicate the set of records you are showing? Yes, there's an answer, but I've gone far enough on a guess. If I'm on the right track, let me know and someone will continue from here. BTW, how do you create the data for ID# in DB1? 'Cause if you're just using Status(RecordID), you're asking for trouble. Link to comment Share on other sites More sharing options...
Pupiweb Posted April 9, 2003 Share Posted April 9, 2003 I'd use a script like: Set field (gID, ID#) //Stores the original ID# in gID, a global field Duplicate Record Go to related record (Show, Relationship gID->ID# with DB 2) //Selects original related records Set field (gID, ID#) //Stores the new ID# number in gID Perform external script in DB2 (see below) Go to record first Loop Duplicate Record Set field (ID#, Relationship to DB1::gID) //Writes the new ID in the ID# field Omit Record Go to record first Omit Record Exit loop if (status current found count = 0) End Loop Link to comment Share on other sites More sharing options...
Ugo DI LUCA Posted April 9, 2003 Share Posted April 9, 2003 Hi, What is exactly the mess you want to go into... Anyway, supposing your "key field" in DB1 is ID002 and that this ID002 appears as a "foreign key" in DB2, with Line003, ID002.... Then any duplicate records of DB1's ID002 (why would you have duplicate BTW!!!) would be related to Line003 by the "foreign key".... And why (again) would you like to duplicate DB2 records anyway. Finally (as Dan, I'm trying to guess something here.. ), if Line# is a Line Item Unique Id, and you just want to duplicate its records, I would warn you from using the "duplicate" function in the Line Item. Guess what ? I'm not sure of what I'm saying here ... Link to comment Share on other sites More sharing options...
goral Posted April 9, 2003 Author Share Posted April 9, 2003 What is exactly the mess I got into? I have no idea, but maybe by giving more details someone can tell me if I Link to comment Share on other sites More sharing options...
Ugo DI LUCA Posted April 9, 2003 Share Posted April 9, 2003 Hi My best answer. Have a look to the test file I've posted some days ago about a lookup not working (solved now). It's exactly what you are looking for and what Dan suggested. Enter dats to the Line Item with a portal set to "allow creation of related records", where the productID is listed in the portal and all infos populate the line item by a lookup. lookup working now Link to comment Share on other sites More sharing options...
danjacoby Posted April 10, 2003 Share Posted April 10, 2003 Thanx, Ugo. Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 7850 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