1 2 3 Previous Next 32 Replies Latest reply on Jul 18, 2014 10:15 AM by hanstrager

    Help to set a script with conditional parameters

    hanstrager

      Title

      Help to set a script with conditional parameters

      Post

           I've slowly been working on expanding my small database, which has ended up, in me having to manually navigate between a lot of different print layouts, which just isn't effective anymore. My Database holds technical information about making garments.

           I've placed 3 different radio button sets in different tables, to break down and categorize my garments, which acts as switches so you can switch between different needs.

           Switch1: Selects the type of garment. Whether its 'WOVEN' or 'KNIT'

           Switch2: Selects what stage the garment is in: 'SAMPLING', 'PRE PRODUCTION' or 'PRODUCTION'

           Switch3: Selects how many technical pictures i need to attached: '0PIC', '1PIC' or '4PICS'

           Based on the settings of the above 3 switches i need to print a specific layout. I've attahced a small tree diagram to illustrate what I'm trying to do.

           Fx. Switch1 = Woven and Switch2 = Pre production and Switch3 = 4pics then i need to go to 'Layout C'

           just not sure how to approach all these parameters and how to do it most effective.

            

      filemaker.jpg

        • 1. Re: Help to set a script with conditional parameters
          FentonJones

                

               I think this could be done in the script with If, Else If, finally End If steps, each within its place. The "field" being tested could be either a regular or global field, so I'll type it. Example (partial):
                
               If [ Garment Type = "Woven" ]
               If [ Status = "Sampling" ]
               If [ Picture = "OPIC" ]
               Go to Layout "A"
               Else If [ Picture = "1PIC" ]
               Go to Layout "B"
               Else If [ Picture = "4PIC" ]
               Go to Layout "C"
               Else If [ Status = "Prod Samp" ]
               If [ Picture = "OPIC"
               Go to Layout "A"
               etc.
               Else If [ Status = "Production" ]
               etc.
               Else If [ Garment Type = "Knit" ]
               If [ Status = "Sampling" ]
               etc.
               Else
               Beep
               "none matched", test for why not
               you could do this before the above
               End If
          • 2. Re: Help to set a script with conditional parameters
            hanstrager

                 Not 100% sure what you mean with:

                 etc.
                 Else If [ Status = "Production" ]
                 etc.
                 Else If [ Garment Type = "Knit" ]
                 If [ Status = "Sampling" ]
                 etc.
                 Else
                 Beep
                 "none matched", test for why not
                 you could do this before the above
                 End If
                  
                  
                 I've tried the following (for Woven Sampling and Woven Pre Production) Thought I'm not moving to any layout. Is what I'm doing completely wrong?
                  

            If [ Basic Garment::Knit leather woven = "WOVEN/LEATHER" ]
            If [ TECHNICAL SHEET 2::ProductionSampling switch = "SAMPLING" ]

            If [ IsEmpty(TECHNICAL SHEET 2::Picture switch) ]
            Go to Layout [ “PRINT SAMPLING Woven 0 Pic Technical ” (TECHNICAL SHEET 2) ]

            Else If [ TECHNICAL SHEET 2::Picture switch = "1Pic" ]
            Go to Layout [ “PRINT SAMPLING Woven 1 Pic Technical” (TECHNICAL SHEET 2) ]

            Else If [ TECHNICAL SHEET 2::Picture switch = "4Pics" ]
            Go to Layout [ “PRINT SAMPLING Woven 4 Pic Technical ” (TECHNICAL SHEET 2) ]

            End If

            End If

            End If
                                     If
            [ Basic Garment::Knit leather woven = "WOVEN/LEATHER" ]

            If [ TECHNICAL SHEET 2::ProductionSampling switch = "PRE PRODUCTION" ]

            If [ IsEmpty(TECHNICAL SHEET 2::Picture switch) ]

            Go to Layout [ “PRINT SAMPLING Woven 0 Pic Technical ” (TECHNICAL SHEET 2) ]

            Else If [ TECHNICAL SHEET 2::Picture switch = "1Pic" ]

            Go to Layout [ “PRINT SAMPLING Woven 1 Pic Technical” (TECHNICAL SHEET 2) ]

            Else If [ TECHNICAL SHEET 2::Picture switch = "4Pics" ]

            Go to Layout [ “PRINT SAMPLING Woven 4 Pic Technical ” (TECHNICAL SHEET 2) ]

            End If

            End If

            End If

                  

            • 3. Re: Help to set a script with conditional parameters
              philmodjunk

                   Fenton's method can work quite well, but I would set up a different approach. I'd add a table of 18 records and put the layout names into those 18 records. I'd then use a portal to display these layouts along with fields that identify the relevant status, garment type, in image number designations. Then, as the user selects a garment type and then selects a status, the portal filters down to fewer and fewer choices. Clicking a button in the portal row, can then take you to that layout.

                   But I wonder if you really need that capability as it would seem that each technical sheet record would use exactly one of these layouts and thus simply moving from record to record could perform a script that uses the current type, status and number of picture designation for that record to automatically change to the appropriate layout.

              • 4. Re: Help to set a script with conditional parameters
                hanstrager

                     Sorry for my late replies.

                     All my records would need to only match one of the combinations.

                     I tried Fenton's Idea, but didn't completely understand when it came to:

                     Else If [ Status = "Prod Samp" ]
                     If [ Picture = "OPIC"
                     Go to Layout "A"
                     etc.
                     Else If [ Status = "Production" ]
                     etc.
                     Else If [ Garment Type = "Knit" ]
                     If [ Status = "Sampling" ]
                     etc.
                     Else
                     Beep
                     "none matched", test for why not
                     you could do this before the above
                     End If
                      
                     Therefore tried:

                If[Basic Garment::Knit leather woven = "WOVEN/LEATHER"]
                If[TECHNICAL SHEET 2::ProductionSampling switch = "SAMPLING"]

                If[IsEmpty(TECHNICAL SHEET 2::Picture switch)]
                Go to Layout[“PRINT SAMPLING Woven 0 Pic Technical ” (TECHNICAL SHEET 2)]

                Else If[TECHNICAL SHEET 2::Picture switch = "1Pic"]
                Go to Layout[“PRINT SAMPLING Woven 1 Pic Technical” (TECHNICAL SHEET 2)]

                Else If[TECHNICAL SHEET 2::Picture switch = "4Pics"]
                Go to Layout[“PRINT SAMPLING Woven 4 Pic Technical ” (TECHNICAL SHEET 2)]

                End If

                End If

                End If
                                              If
                [Basic Garment::Knit leather woven = "WOVEN/LEATHER"]

                If[TECHNICAL SHEET 2::ProductionSampling switch = "PRE PRODUCTION"]

                If[IsEmpty(TECHNICAL SHEET 2::Picture switch)]

                Go to Layout[“PRINT SAMPLING Woven 0 Pic Technical ” (TECHNICAL SHEET 2)]

                Else If[TECHNICAL SHEET 2::Picture switch = "1Pic"]

                Go to Layout[“PRINT SAMPLING Woven 1 Pic Technical” (TECHNICAL SHEET 2)]

                Else If[TECHNICAL SHEET 2::Picture switch = "4Pics"]

                Go to Layout[“PRINT SAMPLING Woven 4 Pic Technical ” (TECHNICAL SHEET 2)]

                End If

                End If

                End If

                                              would have thought similar would have worked, but doesn't move me anywhere?

                      

                • 5. Re: Help to set a script with conditional parameters
                  philmodjunk

                       If it doesn't take you to the correct layout, the expression inside one of the IF steps is not evaluating as you expect it to evaluate. If you have FileMaker Advanced, enable the script debugger and data viewer before starting this script and then step through the script in order to see exactly how the script evaluates so that you can figure out which IF step merits a closer look.

                       If you do not have advanced, you can cobbler together a crude approximation of this method by temporarily inserting some show custom dialog steps that identify in their dialog text which part of the script just executed to produce that message.

                  • 6. Re: Help to set a script with conditional parameters
                    hanstrager

                         It works - found a spelling mistake.

                         Just have one last mistake I'm not sure how to put together this in one script step:

                    If[IsEmpty(TECHNICAL SHEET 2::Picture switch)]
                    Go to Layout[“PRINT SAMPLING Woven 0 Pic Technical ” (TECHNICAL SHEET 2)]

                    Realised that my picture switch is never empty, it only hides/showes 1 container - 4 container fields.

                         So I want to go to the layout: “PRINT SAMPLING Woven 0 Pic Technical ” If Picture switch = 1pic and pic 5 is empty or Picture switch = 4 pics and pic1, pic2, pic3 and pic4 is empty.

                    Not sure how to put this together to one script step?

                    • 7. Re: Help to set a script with conditional parameters
                      philmodjunk

                      My best guess:

                      If [ ( Yourtable::Picture switch = "1pic" and IsEmpty ( Yourtable::pic 5 ) ) or
                                 ( YourTable::Picture switch = "4 pics" and IsEmpty ( YourTable::pic1 & YourTable::pic2 & YourTable::pic3 & YourTable::pic4 ) ) ]

                      • 8. Re: Help to set a script with conditional parameters
                        hanstrager

                             Works - Thanks

                             Realised there's one problem with my script. Not sure if it's possible to fix this or not.

                             As described in the beginning, the scripts directs me to print layouts. The problem arises when i fx sort all my records by woven/knit and want to print all my 'woven' records in one go. All these records will have different configurations - some might be in sampling others in production stage, and would therefore require to use different print layouts. Is there a way the script can check the found set what layout needs to be chosen when printed?

                        • 9. Re: Help to set a script with conditional parameters
                          philmodjunk

                               But as you have just stated, not all records in the found set should be printed on the same layout. Either you include sufficient criteria in your search process to exclude all records that don't require a different layout (so you can use "records being browsed" to print them in one batch print job) or you print them in a script that prints them one at a time (with the current record option), looping through the found set and checking field values for each record in order to go to the best layout for printing that record.

                          • 10. Re: Help to set a script with conditional parameters
                            hanstrager

                                 Not sure where to start when creating the loop that loops through the found set and checks all field values in each record before printing.

                            • 11. Re: Help to set a script with conditional parameters
                              philmodjunk

                                   It shouldn't have to check "all field values" just the field or fields that identify which layout is appropriate for that record.

                                   A basic out line might look like this if all the layouts involved are based on the same table occurrence:

                                   Go to Record/Request/Page [First]
                                   Loop
                                      If [//test field values here to identify the correct layout required]
                                         Go to layout [specify a layout here]
                                      Else If [//test for a different layout goes here ]
                                          Go to layout
                                      Else
                                           Go to Layout
                                      End If
                                      Print [//make sure to specify the "current record" option with this print step.]
                                      Go to Record/Request/Page [ Next ; Exit After Last ]
                                   End Loop

                              • 12. Re: Help to set a script with conditional parameters
                                hanstrager

                                     But what if it's a combination of the 3 fields that decides what layout to go to?

                                • 13. Re: Help to set a script with conditional parameters
                                  philmodjunk

                                       Then the expression inside the  [ ] of the if step needs to check all three fields.

                                       Example:

                                       IF [ Table::Type = "woven" and Table::Status = "Preliminary" And Table::Approval = "Pending" ]
                                          Go to Layout ["Woven Sampling"

                                  • 14. Re: Help to set a script with conditional parameters
                                    hanstrager

                                         Ok Think I'm almost there.

                                         Have this loop and seems to work. Instead of a print I put 'save as PDF'. Is there a way to have the script loop through the script without pulling up the 'Save as Screen' for every single record?

                                         Is there also a way to automatically save the PDF's as the same name as my record? (using the input from one of my fields)

                                    1 2 3 Previous Next