July 1, 201312 yr Hi Everybody! This doesn't seem too complicated at first blush, but I've been wrestling with it for over a week with no success. Goal: I need the all Children of a single designated Parent to be duplicated among all of the child-less records in a found set of Parents. This function is useful where the user wants to avoid manually typing into the database duplicate Children records among tons of Parents. I googled the forums and the net in general for instruction/articles, and couldn't find anything. Any thoughts would be much appreciated... Thank you! -J
July 1, 201312 yr One approach you could try is: 1. Go to related children from the designated parent 2. Go back to the Parent layout 3. Loop through the parent records, and if IsEmpty( related::child ID ), import the child records. - i.e., each time through the loop: - capture the parent ID in a variable - go to child layout and import - replace parent ID with the variable - go back to parent layout - go to next record Note: you must do this all in the same window. Step 1 establishes the found set of children that will be imported, but it won't work if you use multiple windows.
July 2, 201312 yr Author I think I might have it. The steps are laid out below. I tested it with successful results, and it works but for one problem: the script kick to early, as described in Step 3 below. So close!! I'd certainly appreciate any advisement : ) Thanks and Warm Regards, J Propogate Duplicate Issues Step 1 Script: //This script sets the variable for the current Parent record containing the Children that need to be duplicated and assigned to each Parent in a found set of unrelated Parents in the same table.// Set Variable [ $$TitleIDforNewIssues; Value:Titles::ID_TitleRecord ] Perform Script [ “Propogate Duplicate Issues Step 2” ] Propogate Duplicate Issues Step 2: //This next step enables the user to find the Parents who will have the duplicate children assigned to them. It accords a pause, so that the user can omit select records from list view before continuing to step 3 below.// Go to Layout [ “FIND_Titles” (Titles) ] Enter Find Mode [ ] [ Pause ] Perform Find [ ] If [ Get(FoundCount)=0 ] Show Custom Dialog [ Title: "Message"; Message: "No records match this request."; Default Button: “OK”, Commit: “No” ] Perform Script [ “Cancel Find” ] Else Go to Layout [ “Listview_Titles For Duplicate Issues” (Titles) ] Enter Browse Mode Sort Records [ Keep records in sorted order; Specified Sort Order: Titles::Titles_DXNumber; ascending ] [ Restore; No dialog ] Go to Record/Request/Page [ First ] Halt Script End If Propogate Duplicate Issues Step 3: //This last script sets the variable for the first parent in the found set and sets a variable with it's ID. It then finds all the issues to be duplicated and assigned to that first parent, and then does so. Then it moves onto the next Parent and does the same until there are no more Parents left. The Problem: The script moves onto the next Parent, processes it, and then quits, despite the fact that there are 184 additional Parents wanting their duplicated Children!// Go to Record/Request/Page [ First ] Loop Set Variable [ $TitleIDofChildlessParent; Value:Titles::ID_TitleRecord ] Go to Layout [ “FIND_Issues” (Issues) ] Enter Find Mode [ ] Set Field [ Issues::ID_TitleRecord; $$TitleIDforNewIssues ] Perform Find [ ] Go to Record/Request/Page [ First ] Loop Duplicate Record/Request If [ Issues::ID_TitleRecord ≠ $TitleIDofChildlessParent ] Set Field [ Issues::ID_TitleRecord; $TitleIDofChildlessParent ] Omit Record Go to Record/Request/Page [ First ] Omit Record End If Go to Record/Request/Page [ Next; Exit after last ] End Loop Go to Record/Request/Page [ Next; Exit after last ] End Loop Go to Layout [ “FIND_Titles” (Titles) ] Enter Find Mode [ ] Set Field [ Titles::ID_TitleRecord; $$TitleIDforNewIssues ] Perform Find [ ] Go to Layout [ “Titles_IssuesViewInPortal” (Titles) ]
July 2, 201312 yr Author Can you describe what this is all about? What are these entities? Sure thing! The Parent records are rare book titles. You can see the "Titles" table referred to throughout. The Children records are legal issues. Specifically, they're records which describe revisions which must be made to the book title contracts. In many cases, the contract for the acquisition of a book pertains not to a single book title, but to many book titles. For example, I may wish to pay you $5,000 for 200 different rare books. In the event there's a scrivener's error in the contract for those 200 books, that error will pertain to all 200 individual database "children" records for the 200 books. Instead of forcing the user to go 'round to all 200 book records, I'd like him to be able to conduct a search to obtain the found set of 200 books (each being child-less of issues), then hit a button and automatically propagate the each book record with all the issues pertaining to the designated contract for those books. Let me know if I can be of further help in clarifying, and thanks in advance for your consideration : ) -J
Create an account or sign in to comment