7 Replies Latest reply on Jan 23, 2013 3:49 PM by hanstrager

    Help Dublicate record with multiply portals

    hanstrager

      Title

      Help Dublicate record with multiply portals

      Post

           I have a problem with a script that should copy a record with multiply portals.

           I so far got the record copied and have it copy one of my portals with the following scripts

            

      Set Error Capture [ On ]

      If [ LeftWords(Get ( LayoutName );1) ="TECHNICAL" and not IsEmpty(Line Items::xLine items ID) ]

      Commit Records/Requests

           [ Skip data entry validation; No dialog ]

      Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ]

           [ Show only related records ]

      Go to Layout [ original layout ]

      Set Variable [ $Lines; Value:1 ]

      End If

      Duplicate Record/Request

      If [ Get ( LastError )=200 ]

      Show Custom Dialog [ Title: "Cant Dublicate"; Message: "You Don't have privileges to dublicate" & Lower(LeftWords(Get

           (LayoutName);1)) &

           "."; Buttons: “OK” ]

      Else

      If [ LeftWords(Get ( LayoutName );1) ="TECHNICAL" and $Lines=1 ]

      Perform Script [ “dublicate lines from fabric ” ]

      End If

      End If

            

           And then use a sub script called “dublicate lines from fabric” with the following script:

            

      Set Variable [ $ID; Value:TECHNICAL SHEET 2::xTechnical sheet_ID ]

      Go to Layout [ “Line Items” (Line Items) ]

      Freeze Window

      Loop

      Duplicate Record/Request

      Set Field [ Line Items::TechSheetID_FK; $ID ]

      Omit Record

      Go to Record/Request/Page

           [ First ]

      Omit Record

      Exit Loop If [ Get ( FoundCount )=0 ]

      End Loop

      Go to Layout [ original layout ]

            

           In my naivety I thought I could just make another script and use “Perform script” and use the above script 4 times according to what portal I want to copy, but then obviously It makes 4 new records with a copied portal on each.

           How do I make the above script to make a duplicate of a record from TECHNICAL SHEET 2 which includes different line items in my portals (a portal for fabric, zips, buttons, other)?

        • 1. Re: Help Dublicate record with multiply portals
          hanstrager

               this is btw my realtionship graph if that will help...

          • 2. Re: Help Dublicate record with multiply portals
            hanstrager

                 I've got this had help to make this script that seems a bit easier and does the same, but dosen't know exactly have to have tis work with multiply portals either

                  

                 Freeze Window
                 Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ]
                 Duplicate Record/Request
                 Set Variable [ $TECHSHEETID; Value:TECHNICAL SHEET 2::xTechnical sheet_ID ]
                 Go to Record/Request/Page [ $RecordNumber ]
                 [ No dialog ]
                 If [ not IsEmpty(Line Items::TechSheetID_FK) ]
                 Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ]
                 [ Show only related records ]
                 Go to Record/Request/Page
                 [ First ]
                 Loop
                 Duplicate Record/Request
                 Set Field [ Line Items::TechSheetID_FK; $TECHSHEETID ]
                 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
                  

            • 3. Re: Help Dublicate record with multiply portals
              philmodjunk

                   The following portion of the script would need to be duplicated, then updated to reference a different table, layout and fields for each such portal:

                   If [ not IsEmpty(Line Items::TechSheetID_FK) ]
                      Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ][ Show only related records ]
                      Go to Record/Request/Page [ First ]
                      Loop
                         Duplicate Record/Request
                         Set Field [ Line Items::TechSheetID_FK; $TECHSHEETID ]
                         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[$recordNumber ;no dialog ]
                   End If

              • 4. Re: Help Dublicate record with multiply portals
                hanstrager

                     i've used this, but it only dublicates the records in my fabric portal and not in my zip portal:

                      

                     dublicate techsheet Copy
                     Freeze Window
                     Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ]
                     Duplicate Record/Request
                     Set Variable [ $TECHSHEETID; Value:TECHNICAL SHEET 2::xTechnical sheet_ID ]
                     Go to Record/Request/Page [ $RecordNumber ]
                     [ No dialog ]
                     If [ not IsEmpty(Line Items::TechSheetID_FK) ]
                     Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ]
                     [ Show only related records ]
                     Go to Record/Request/Page
                     [ First ]
                     Loop
                     Duplicate Record/Request
                     Set Field [ Line Items::TechSheetID_FK; $TECHSHEETID ]
                     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
                     If [ not IsEmpty(line items zip::xZip_ID) ]
                     Go to Related Record [ From table: “line items zip”; Using layout: “line items zip” (line items zip) ]
                     [ Show only related records ]
                     Go to Record/Request/Page
                     [ First ]
                     Loop
                     Duplicate Record/Request
                     Set Field [ line items zip::xtechsheetFK; $TECHSHEETID ]
                     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 [ No dialog; $recordNumber ]
                     End If
                      

                • 5. Re: Help Dublicate record with multiply portals
                  hanstrager

                       think I got it, it seems to work is this how you mean it should be copied fx for 2 portals the fabric and zip:


                       Freeze Window
                       Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ]
                       Duplicate Record/Request
                       Set Variable [ $TECHSHEETID; Value:TECHNICAL SHEET 2::xTechnical sheet_ID ]
                       Go to Record/Request/Page [ $RecordNumber ]
                       [ No dialog ]
                       If [ not IsEmpty(Line Items::TechSheetID_FK) ]
                       Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ]
                       [ Show only related records ]
                       Go to Record/Request/Page
                       [ First ]
                       Loop
                       Duplicate Record/Request
                       Set Field [ Line Items::TechSheetID_FK; $TECHSHEETID ]
                       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 [ $recordNumber ]
                       [ No dialog ]
                       End If
                       If [ not IsEmpty(line items zip::xZip_ID) ]
                       Go to Related Record [ From table: “line items zip”; Using layout: “line items zip” (line items zip) ]
                       [ Show only related records ]
                       Go to Record/Request/Page
                       [ First ]
                       Loop
                       Duplicate Record/Request
                       Set Field [ line items zip::xtechsheetFK; $TECHSHEETID ]
                       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 [ $recordNumber ]
                       [ No dialog ]
                       End If
                        

                  • 6. Re: Help Dublicate record with multiply portals
                    philmodjunk

                         I used script pretty in the Known Bugs List Database plus some editing to make your script easier to read:

                         Freeze Window
                         Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ]
                         Duplicate Record/Request
                         Set Variable [ $TECHSHEETID; Value:TECHNICAL SHEET 2::xTechnical sheet_ID ]
                         Go to Record/Request/Page [ $RecordNumber ][ No dialog ]
                         If [ not IsEmpty(Line Items::TechSheetID_FK) ]
                                Go to Related Record [ From table: “Line Items”; Using layout: “Line Items” (Line Items) ][ Show only related records ]
                                Go to Record/Request/Page[ First ]
                                Loop
                                        Duplicate Record/Request
                                        Set Field [ Line Items::TechSheetID_FK; $TECHSHEETID ]
                                        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 [ $recordNumber ][ No dialog ]
                         End If
                         If [ not IsEmpty(line items zip::xZip_ID) ]
                                Go to Related Record [ From table: “line items zip”; Using layout: “line items zip” (line items zip) ][ Show only related records ]
                                Go to Record/Request/Page[ First ]
                                Loop
                                        Duplicate Record/Request
                                        Set Field [ line items zip::xtechsheetFK; $TECHSHEETID ]
                                        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 [ $recordNumber ][ No dialog ]
                         End If

                         Yes, that looks correct for duplicating the set of related records in the two related tables.

                    • 7. Re: Help Dublicate record with multiply portals
                      hanstrager

                           works perfect - thank you