6 Replies Latest reply on Oct 4, 2012 1:42 PM by Emmanuel

    Duplicate Record and all portals

    markskm

      Title

      Duplicate Record and all portals

      Post

      Hi,

      I have a record that incorporates a portal and I wish to be able to duplicate this record and ALL it's portal rows - ideally with a script.

      Thanks in advance.

        • 1. Re: Duplicate Record and all portals
          philmodjunk

          Here's a link to where you'll find a script that does this:

          Duplicating Bill Of Materials (duplicating portal line items)

          • 2. Re: Duplicate Record and all portals
            mgores

            sorry, my original post was assuming you were just duplicating the parent record rather than creating a new parent record and wanting the same child records.

            • 3. Re: Duplicate Record and all portals
              markskm

              Hi PhilModJunk,

              I'm a script virgin so bear with me.

              I have a Line Items layout that contains seven fields: Code, Size 1, Size 2, AW Hours, Create PDF, A3 Runouts and A4 runouts. All this information is looked up from a layout called Templates. I have another layout called Cost Estimate which contains a portal where I can access all the information from Line Items. Everything works fine, I can create a new record in Cost Estimate and add new entries within the portal that pulls the information in from Line Items.

              The problem I have is that when I duplicate a record in Cost Extimate the portal information doesn't duplicate but the rest of the information does. I've looked at the script you directed me to and although I know how to create and edit a script usining the basic Filemaker options I'm struggling with what layout information goes where within each individual calculation. 

              Would you be so kind to edit the sript, showing me where my layouts etc should be entered.

              Thanks in advance.

              Mark

              • 4. Re: Duplicate Record and all portals
                philmodjunk

                The layout names do not need changing unless the name of your line items layout differs in some way. The only change you need to make except to use the primary/foreign key field names for your tables in place of those in the script. Since I don't know the names of those fields, I'll call them: Cost Estimate::__pkCostEstimateID and LineItems::_fkCostEstimateID. Subsitute your field names for those when you implement this script:

                Changes are in Red.

                #Starts from Cost Estimate layout
                Freeze Window
                Set variable [$RecordNumber ; Value: Get ( RecordNumber ) ]
                Duplicate Record
                Set Variable [$ID ; Cost Estimate::__pkCostEstimateID]
                Go To Record/Request/Page [$RecordNumber]
                If [ Not IsEmpty ( _fkCostEstimateID ) /* there are line items to duplicate */]
                   Go To Related Record [Show only related records; From table: lineItems; Using layout: "lineItems" (lineItems)]
                   Go To Record/Request/Page [first]
                   Loop
                      Duplicate Record
                      Set Field [ LineItems::_fkCostEstimateID ; $ID]
                      Omit Record
                      Go To Record/Request/Page [first]
                      Omit Record
                      Exit loop If [ get ( FoundCount ) = 0 ]
                   End Loop
                   Go To Layout [original layout]
                   Go To Record/Request/Page [Last]
                End IF

                • 5. Re: Duplicate Record and all portals
                  SKY

                   Hi, I'm trying to adapt this script to do a the same for my database.  I've been working on it for a few hours now and can't get it to work.  I was hoping that someone on here might be able to help?  The part of my database that I need help with is the encounter.  When a patient returns, I would like to not have to punch in all the same diagnosis codes (ICD_9_ID).  For each encounter, there are ICD_9_IDs and CPT_IDs.  Often times the CPT codes change, so I'm not interested in duplicating these at this point.  I would just like the new encounter to copy all the ICD_9_IDs over to the new encounter.  The encounter table is related to the ICD9 and CPT code tables via a join table.  My encounter table is set to automatically create and delete records from the join table, so I don't have foreign and primary keys (I'm currently thinking this is my main problem trying to accomplish my goal).  I followed the link that the first responder posted and tried that, but am still having problems.  I assume that my join table is like the line items table from that script and that my ICD_9_ID is similar to the partsid, but haven't been able to get it to work.

                  Any experienced FM users have a life line? :)

                   

                  Relationships

                  Encounter

                  case join

                  • 6. Re: Duplicate Record and all portals
                    Emmanuel

                         Hi PhilModJunk,

                         I was looking at the script to duplicate records and its portals. What I don't understand is the way to add the items  to be duplicated in the portal. In your examples it goes like:


                    If [ Not IsEmpty ( _fkCostEstimateID ) /* there are line items to duplicate */]
                          

                         ...but what is the syntax to add the fields? Is it inside the if brakets? Separated by ";"?

                          

                         Thank you