1 2 Previous Next 16 Replies Latest reply on Mar 21, 2013 4:50 PM by philmodjunk

    How to script : portal rows records to be duplicated Fmp12

    Kaorin

      Title

      How to script : portal rows records to be duplicated Fmp12

      Post

           I work in Fashion company and want to create a “MANUFACTURING SPECIFICATION SHEET” – so that the factories know what type of trims are used and how / where to be applied on a garment quickly and clearly. - I have uploaded an image of the plan FYI to help understand below more clearl.

           We use the same pattern block (or “Style”) for numerous type of fabric. Ie) a Style_ID “JK001” 2-button borelo Jacket will be launched in 5-10 different fabrics. The ideas is that if I entre (or create) the Components & Trims of JK001 once, next time I create a specification sheet for the same Style_ID JK001 for a different fabric, the Components & Trims information (or records) will be duplicated, but with ability to slightly modify at the same time!

           JK001 Jacket comes in 2 fabrics: Tweed and Leather. For the Tweed it comes in Grey and Navy colours, and each colourway of the jacket need to be specified so that the correct colours of trims are applied on the jacket. The jacket has 2 x 20mm metal buttons with a Trim_Code BTM1CM

           Then the JK001 in Leather – this should have same components and same application but I decide that I want to use 2 different kinds of buttons (different Trim_Code's) in the leather jacket to make it different look form Tweed version. So rather than:

              BUTTONS     x 2     20mm     BTN1CM      Front body placket

            

           I want to be able to AMEND the records in this portal raw without affecting a “template” Components & Trims:

            

            BUTTONS     x 1     20mm     BTN1CM      Front body top button

            BUTTONS     x 1     20mm     SHANK1      Front body bottom button

            

           I have visual plan of how the files / tables / portals should look like, but I don’t know how I can do the above.I obviously need to create more tables with list of components per Style_ID/Fabric_ID – but I don’t know what I should do next – do I need to set up a Script? Or is there any other way around to set this up? Please guide me or help me to understand the file set up / relationship / scripts etc..

           Sorry if my explanation is confusing. Any suggestion is much appreciated.

           Thank you.

            

      FILEMAKER.jpg

        • 2. Re: How to script : portal rows records to be duplicated Fmp12
          Kaorin

               Oh thank you very much for the link! I will study and try this and will get back to you if I have any questions.

               Kaorin

          • 3. Re: How to script : portal rows records to be duplicated Fmp12
            Kaorin

                 Dear PhilModJunk,

                 I tried to understand the script & functions (my weakness), and in despear googled youtube for any demonstration to make sense of the script etc.. Like with the other peopled in the past who asked you similar query, I am finding it difficult to apply those scripts...

                 Should I have applied the script to a field in the portal or as I create a new record of the same style or where should i have...? (as a button?)

                 I attached updated plan of the table relationships.

                 The Specsheet (as you call lit BOM Maintable/file) is related to my Line_item of Components and Trims with 2 fields: 

                 = Syle_ID 

                 = Fabric_ID

                 Should I have done it just related to "Style_ID" in order to the script of your suggetsion to work?

                  

                  

                  

            • 4. Re: How to script : portal rows records to be duplicated Fmp12
              philmodjunk

                   The relationship differences (Two match fields instead of one) should have no effect on the script being able to duplicate both the parent record (spec sheets)and the related list of portal records (components). It's based on the relationship so it does not matter whether or not a portal to the related table exists.

                   It does, however, need to be performed from a layout based on the parent table from the parent record that you want to duplicate.

                   It looks like you have several different sets of related records in different tables. If they also need to be duplicated, the script will need additional steps to repeat the process of duplicating them as well.

              • 5. Re: How to script : portal rows records to be duplicated Fmp12
                Kaorin

                     Hello PhilModjunk, thank you for help and I think I'm making a progress !! (even very little), however, now I came to another problem.

                     I made the relationship related to just 1 field rather than 2 fields (prior to receiving your email answer).

                     Anyway, the script of your suggestion certainly did duplicated in the Line_items table layout, however, on the other layout (BOMSpeclayout) the portal is showing the duplicated records under  the same ...record created in BOMSpeclayout. (picture attached). 

                     When I tried to change the Fabric_ID, obviously everything dissapeared from the portal...Could you reconfirim your script based on what I uploaded?

                     I'm not quite sure what I have done wrong...

                     Thank you.

                      

                • 6. Re: How to script : portal rows records to be duplicated Fmp12
                  philmodjunk

                       Make sure that you are referring to the last version of the script at the end of the thread. The original version at the beginning has been found to have an issue if there are multiple parent records in the found set at the time that the script is performed.

                       Your screen shots show that the duplicated line item records are not getting the needed new Fabric ID value. In the example script, there's a step that copies the ID value of the newly duplicated parent record to a variable. Then, inside the loop, there's a set field step that copies the value in the variable into the ID field of the newly duplicated line item.

                       To post a script to the forum:

                         
                  1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                  2.      
                  3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
                  4.      
                  5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                  6.      
                  7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                  • 7. Re: How to script : portal rows records to be duplicated Fmp12
                    Kaorin

                         Thank you! - I updated with the end of thread version, and my script now looks like below. 

                         It's started to duplicated the records, and also copying the value into Style_ID field. I now struggle with the next step

                         - how can I modify the Fabric_ID of the record 2.

                         What is showting in both records in BOM_Spec_Layout is literally duplicated information: from Style_ID to Fabric_ID to the contents in the portal.

                         How can I adjust the script so that it duplicates for the next record with the same Style_ID mainitaining one line of LlINING and one line of SLEEVE LINING but using a different Fabric_ID?

                         Thank you.

                          

                          

                                         

                    Freeze Window

                    Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ] Duplicate Record/Request
                                                       Set Variable
                    [ $STYLQAULITY_ID; Value:LIne_Items::StyleQuality_ID ] Go to Record/Request/Page [ $RecordNumber ]
                    If [ not IsEmpty ( LIne_Items::StyleQuality_ID )/*LIne_Items::TypeTrim*/ ]

                    Go to Related Record [ From table: “LIne_Items”; Using layout: “LIne_Items” (LIne_Items) ] Go to Record/Request/Page

                    [ First ]

                    Loop

                    Duplicate Record/Request

                    Set Field [ LIne_Items::Style_ID; BOM_Spec_Layout::StyleID ]

                    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 ]

                    page1image8328page1image8488

                    End If 

                          

                    • 8. Re: How to script : portal rows records to be duplicated Fmp12
                      philmodjunk

                           How is the new Fabric ID generated? From where will that value come so that the script can use it to update the new records with it?

                           Is this a value that must be specified by the user before performing this script?

                      • 9. Re: How to script : portal rows records to be duplicated Fmp12
                        Kaorin

                             Hi PhilModJunk,

                             At the moment, for the Fabric_ID, user can manuary enter a value to this field.  That's how I set it up, only because I don't know the other way around to it. If a user manually enter a different Fabric_ID value to this fiel in Record2 after performing the script on the previous thread. off course the records in the portal dissapears as the relationship with the Line_Item is based on StyleFabric_ID (caluculation field of Style_ID & Fabric_ID ) if a different fabric_ID value is entered. Also problem of having the same line_item twice in Record1.

                             I'm not sure whats the beat way to rectify this issue; is it possible to add a step in the above script so prior to duplication it pauses and a user can enter any value to the Fabric_ID field?

                             or perhaps there are more better way of doing this?

                             Thanks. 

                              

                        • 10. Re: How to script : portal rows records to be duplicated Fmp12
                          philmodjunk

                               The user can enter the new Fabric ID into a separate field with global storage before performing this script.

                               Then you can add a set field step inside the loop to update each newly created line item record with the value in this global field.

                          • 11. Re: How to script : portal rows records to be duplicated Fmp12
                            Kaorin

                                                Thank you for prompt response - however, I am little lost about both of what you suggested.

                                                Would you be able to describe and guide me step-by-step as to what I need to do in order to follow your suggestion?

                                                Thank you.

                                                 

                                  

                            • 12. Re: How to script : portal rows records to be duplicated Fmp12
                              philmodjunk

                                   Please post a copy of your current script. Then I can tell you exactly where to add a set field step to set the Fabric ID field of the newly created line item record to the value of the global field.

                                   To post a script to the forum:

                                     
                              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                              2.      
                              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
                              4.      
                              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                              6.      
                              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                              • 13. Re: How to script : portal rows records to be duplicated Fmp12
                                Kaorin

                                     Oh, thank you! Ok, here is the script I have (run on BOM Spec Layout) is this is exactly as it is below

                                     WOuld you be able to add/modify where necessary to achive what I am trying to do?

                                     Thank you.

                                     Kaorin

                                      

                                Freeze Window

                                Set Variable[ $RecordNumber; Value:Get ( RecordNumber ) ]Duplicate Record/Request
                                                    Set Variable
                                [ $STYLQAULITY_ID; Value:LIne_Items::StyleQuality_ID ]Go to Record/Request/Page[ $RecordNumber ]
                                If[ not IsEmpty ( LIne_Items::StyleQuality_ID )/*LIne_Items::TypeTrim*/ ]

                                Go to Related Record[ From table: “LIne_Items”; Using layout: “LIne_Items” (LIne_Items) ]Go to Record/Request/Page

                                [ First ]

                                Loop

                                Duplicate Record/Request

                                Set Field[ LIne_Items::Style_ID; BOM_Spec_Layout::StyleID ]

                                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

                                      

                                • 14. Re: How to script : portal rows records to be duplicated Fmp12
                                  philmodjunk

                                       Let's clean up the format a little with the ScriptPretty custom function:

                                       Freeze Window
                                       Set Variable [ $RecordNumber; Value:Get ( RecordNumber ) ]
                                       Duplicate Record/Request
                                       Set Variable [ $STYLQAULITY_ID; Value:LIne_Items::StyleQuality_ID ]
                                       Go to Record/Request/Page [ $RecordNumber ]
                                       If [ not IsEmpty ( LIne_Items::StyleQuality_ID )/*LIne_Items::TypeTrim*/ ]
                                           Go to Related Record [ From table: “LIne_Items”; Using layout: “LIne_Items” (LIne_Items) ]
                                           Go to Record/Request/Page [ First ]
                                           Loop
                                               Duplicate Record/Request
                                               Set Field [ LIne_Items::Style_ID; BOM_Spec_Layout::StyleID ]
                                          Set Field [Line_Items::Fabric_ID ; Globals::gNewFabricID ]
                                               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

                                       You can define gNewFabricID in any table that you want so long as you give it global storage in field options. In this example, I've defined it in a field named "globals". SInce global fields can be accessed from any script, layout, calculation in your file, it's often a good idea to define them in their own special table to better keep track of them.

                                  1 2 Previous Next