10 Replies Latest reply on Feb 9, 2013 7:21 AM by as2njohn

    Copy all portal row and paste another portal which is created in different table

    traart

      Title

      Copy all portal row and paste another portal which is created in different table

      Post

      Hi everyone

      I have two different tables and one join table (have a relationship) and two portals which is in join table. Two portals have some same field and i have two seperate layouts created in different tabel

      first portal has

      product_id product_name quantity quantity_send

      second has

      product_id product_name quantity_send price  total

      i want to copy first portal's rows which has the quantity_send field is not empty.

      and paste to second portal by pressing button (i want to use script)

      how can i do this 

      sorry for my english :/

        • 1. Re: Copy all portal row and paste another portal which is created in different table
          philmodjunk

          What are the relationships one which your portals are based? On a layout to what table? Why do you have two portals instead of just one?

           

          • 2. Re: Copy all portal row and paste another portal which is created in different table
            traart

            i use this database in manufacturing company

            we give order some componenet to our sub companies. 

            first table (and layout) is given order table which only contain given quantity of product.

            i need second table because when i order 2000 pcs component. It cames day by day like 100 and 200 pieces till complete the 2000 order . i must control and track each parcels 

            Second table (layout) just for track total amount of each parcel.

            so two different portals fields nearly same axcept  second portal's price field.

            table layout is

            ORDER AND COMING ORDER TABLES related by join table which holds portal records 

            PRODUCT TABLE - JOIN TABLE  - ORDER TABLE

             - COMING ORDER TABLE

            • 3. Re: Copy all portal row and paste another portal which is created in different table
              philmodjunk

              I understand that you have this in Manage | Database | Relationships:

              Product---<JoinTable>----Order

              Relationship details are probably(but with your field names in place of mine):
              Product::_pk_ProductID = JoinTable::_fk_ProductID
              Order::_pk_OrderID = JoinTable::_fk_OrderID

              I can't tell from your posts what "coming order table" is. Is this a data table created on the Tables tab of Manage | Database or a table occurrence created on the Relationships tab?

              How is it related to the other tables (or table occurrences) you have here?

              You indicate that you have a layout based on Order. When you double click on each of the portals on this layout while in layout mode, what is listed in the Show Records From drop down for each?

              • 4. Re: Copy all portal row and paste another portal which is created in different table
                traart

                hoCOMING ORDER TABLE means how many companets came to factory (which i gave before) (we can say ORDER CAME TABLE)

                PRODUCT is related with JOIN TABLE (wich holds portal records)

                and also

                JOIN TABLE is related with ORDER GIVEN TABLE and ORDER CAME TABLE 

                ORDER GIVEN TABLE has first portal has fields below

                product_id  -  product_name   -  quantity  -  quantity_came

                ORDER CAME TABLE has second portal has fields below

                product_id  -  product_name   -  quantity_came   -   price   -    total price (price*quantity)

                ORDER GIVEN table also has button which has script that to copy all portal rows (product_id field and quantit_came field) (which quantity_came field is not empty)

                and paste ORDER CAME TABLE's portal fields (product_id and quantity_came fields)

                how can i do this script ?

                • 5. Re: Copy all portal row and paste another portal which is created in different table
                  philmodjunk

                  I cannot help you without an answer to this question that I have already asked:

                  When you double click on each of the portals on this layout while in layout mode, what is listed in the "Show Records From" drop down for each portal?

                  JOIN TABLE is related with ORDER GIVEN TABLE and ORDER CAME TABLE 

                  Yes, but HOW are they related to the join table?

                  I have to know that and whether ORDER GIVEN TABLE and ORDER CAME TABLE are really two different tables or just two boxes in Manage | Database | Relationships with the same data source table before I can suggest an answer here.

                  • 6. Re: Copy all portal row and paste another portal which is created in different table
                    traart

                    Each portal show records from JOIN TABLE

                    ORDER GIVEN and ORDER CAME two different tables (and each have one portal ( Each portal show records from JOIN TABLE ) )

                    • 7. Re: Copy all portal row and paste another portal which is created in different table
                      philmodjunk

                      It might help to read this tutorial to understand the difference between a table and a table occurrence. This is a critical difference with regards to answering the questions you have asked here:  Tutorial: What are Table Occurrences?

                      Are ORDER GVEN and ORDER CAME tables or layouts? Tables can't have portals but layouts can have portals so your last post adds to my confusion here.

                      If ORDER GIVEN and ORDER CAME are two different layouts, each with a portal to the Join Table, how are the portals different. I realize the fields listed are different, but either you have a different portal filter or a different relationship here (or both ). Otherwise, any record shown in the portal on one layout would also be visible on the other and you would not be asking how to copy a portal record from one to the other here.

                       

                      • 8. Re: Copy all portal row and paste another portal which is created in different table
                        traart

                        ORDER GIVEN is table and has a one layout and layout has a one portal which show records from JOIN TABLE

                        ORDER CAME is table and has a one layout and layout has a one portal which show records from JOIN TABLE

                        ORDER GIVEN is related with JOIN table  ( ORDER GIVEN::primary_key_ordergiven_id  -  JOIN::foreign_key_ordergiven_id )

                        ORDER CAME is related with JOIN table  ( ORDER CAME::primary_key_ordercame_id  -  JOIN::foreign_key_ordercame_id )

                        and also i have PRODUCTS table  (PRODUCTS::primary_key_product_id  - JOIN::foreign_key_product_id )

                        Portal records are not same because primary key id is different for each portals. 

                        In order to do this copy paste scrip. I did before

                        go to portal row firs

                        copy product_id

                        go to layout ....

                        paste product_id

                        go to original layout

                        go to portal row first

                        go to portal row next

                        copy product_id

                        go to layout ....

                        go to portal row first

                        go to portal row next

                        paste product_id 

                        For each 10 portal rows i use this script ten times. (which is no brainer). I think that i must use loop script but i could not do.

                        I want loop script copy produt_id field for each portal row to paste other portal BUT

                        I want to stop loop script when the product_id field is empty.

                        And i want loop script is also know if quantity_came field is empty do not copy related portal row 

                        Sorry again for my English. And i am very thankfull for trying to help me :)

                        • 9. Re: Copy all portal row and paste another portal which is created in different table
                          philmodjunk

                          Thanks, that provides the detail I needed.

                          You have these relationships (Let me know if I make a mistake here):

                          Products------<Join>---------ORDER CAME
                                                 |
                                                 |
                                                 ^
                                          ORDER GIVEN

                          With the match fields you've given here.

                          First, Copy and Paste are not the best options for this operation. Your user may have copied data to the clipboard and this script will destroy any such data in the clipboard. Copy and Paste will also fail to work if the field they copy from or paste to are not present on the given layout. That can create problems when someone edits the layout to remove a field and then a script no longer works as expected.

                          We can use Set Field and Set Variable to avoid those problems.

                          You can loop through the rows of a portal, but the steps used can't specify exactly which portal they are to operate on. That's not a problem when your layout has only one portal, but if you later add another portal for another use, the script may suddently fail to work correctly. I thus think it's safer to use the following approach:

                          I may get this backward, moving date from "given" to "came" when you want to move from "came" to "given". If so you'll need to change the script accordingly. I'm also assuming that you also need to create a new record in the other "order" table so you can get it's ID number for the new records in the join table.

                          If [ Not IsEmpty ( Join::foreign_key_ordergiven_id ) ]
                             Go To Layout [OrderCame]
                             New Record/Request
                             Set Variable [$CameID ; Value: ORDER CAME::primary_key_ordercame_id  ]
                             Go To Layout [original layout]
                             Go To Related Record [Show only related records; From table: Join; Using layout: "Join" (Join)]
                             Go To Record/Request/Pate [First]
                             Loop
                                Duplicate Record
                                Set Field [Join::foreign_key_ordergiven_id ; "" ] //clear new record's key field so it doesn't appear in wrong portal
                                Set Field [Join::foreign_key_ordercame_id ; $CameID ]
                                Omit Record
                                Go To Record/Request/Page [First]
                                Omit Record
                                Exit Loop If [Get ( FoundCount ) = 0 ]
                             End Loop
                             Go To Layout [OrderCame]
                          End If

                          • 10. Re: Copy all portal row and paste another portal which is created in different table
                            as2njohn

                                 hi phil..

                                 i have similar problems encountered copy portal data to new record portal..

                                 i have purchased order layout and portal data.. 

                                 .. i want to copy all portal data from purchased order to stock recieved layout