1 2 Previous Next 24 Replies Latest reply on Sep 3, 2013 6:02 AM by JohnEriksson

    Passing Multiple Script Parameters (Field Value and Text String)

    johnhorner

      Title

      Passing Multiple Script Parameters (Field Value and Text String)

      Post

      i am confused about passing multiple script parameters.  i currently am passing one parameter which is a field value passed in the form: TOC::FIELD and it works fine.  now i want to add a second parameter and i understand that there is a method for chaining multiple parameters together using a pipe ("|") and then extracting the values on the other side.  i tried to add a text value, "EMPLOYEE" for example, in this format: TOC::FIELD|EMPLOYEE, but i get an error saying that the specified field cannot be found (i guess it is reading the whole expression as a single field name).  can someone tell me the correct way to pass the field value and the text string as parameters?  thanks.

        • 1. Re: Passing Multiple Script Parameters (Field Value and Text String)
          philmodjunk

          Using the "pipe" separater, you'd need an expression like: TOC::FIELD & "|EMPLOYEE"

          I prefer to pass a list of parameters in this fashion: List ( TOC::Field ; "Employee" )

          Extracting the individual values from within the script is a touch simpler:

          Getvalue ( Get ( ScriptParameter ) ; 1 )  will return the TOC::Field parameter

          GetValue ( Get ( ScriptParameter ) ; 2 ) will return the second parameter, the literal text "Employee".

          Note that in either fashion, you sometimes have to coerce non text data types inorder to use the values successfully in your script.

          GetAsNumber ( Getvalue ( Get ( ScriptParameter ) ; 1 ) ) or

          getAsDate ( Getvalue ( Get ( ScriptParameter ) ; 1 ) )

          to give two examples of coercing the data type.

          • 2. Re: Passing Multiple Script Parameters (Field Value and Text String)
            johnhorner

            Thanks philmodjunk... i'm closer but still having some difficulty.  at least i can specify the multiple parameters now!  as you pointed out, my problem now is evaluating them.  the first parameter is a container field which has a picture (png file) in it.  i have an expression to see if the picture in this container field matches one stored in a global field.  it doesn't seem to evaluate correctly simply using "getvalue" (this is how i have it set up inside the "if" statement: GetValue ( Get ( ScriptParameter ) ; 1 ) = GraphicsElements::g_Graphics [9] ) and i couldn't find a "getaspicture" function (or equivalent) to place in front of it.  is there such a thing?  how would you extract the container field's contents such that you could use it in an: "if "the contents of the container field passed in the script parameter" = "the global container field" " kind of way?

            • 3. Re: Passing Multiple Script Parameters (Field Value and Text String)
              johnhorner

              ooops... disregard that last post.  i just discoverd that i had disabled some other script steps that made it appear as though it was not evaluating correctly.  my bad... everything is working fine.  this is an awesome new technique you have tough me.  thanks!!!

              • 4. Re: Passing Multiple Script Parameters (Field Value and Text String)
                johnhorner

                hi philmodjunk... i was hoping you can answer a follow up question for me?  i am passing a script parameter as you suggested in a list and it looks like this:

                List ( contacts_CONTACT_RELATIONSHIPS_Employees::ArrowOrPlusSign ; "Employee" )

                to evaluate it i have an expresssion which looks like this:

                GetValue ( Get ( ScriptParameter ) ; 1 ) = GRAPHIC_ELEMENTS::g_Arrows [3] and GetValue ( Get ( ScriptParameter ) ; 2 ) = "Employee"; "NavigateToEmployee"

                it worked great!  the problem now is that i am passing a similarly formatted parameter (List ( products_PRODUCTS_LiveSearch::Match_B ; "Products" ) and i am trying to use the "count" function but i cannot get it to evaluate correctly (or at all... it displays a question mark in the dialog i am using to troubleshoot.  i have tried the following formats to get a value and none of them are working:

                Count ( GetField ( GetValue (  Get ( ScriptParameter ) ; 1 ) ) )

                Count ( GetField ( "\"" & GetValue ( Get ( ScriptParameter ) ; 1 ) & "\"" ) )
                Count ( GetField ( GetAsText ( GetValue ( Get ( ScriptParameter ) ; 1 ) ) ) )
                Count ( GetField ( "\"" & Get ( ScriptParameter ) & "\"" ) )
                Count ( GetField ( Get ( ScriptParameter ) ) )

                **Count ( GetValue ( Get ( ScriptParameter ) ; 1 ) )

                **won't allow this expression.  error message says "In  the function Average, Count, Extend, GetRepetition, Max, Min, NPV,  StDev, Sum, GetSummary or GetNthRecord, an expression was found where a  field alone is needed."

                the straightforward expression: Count ( products_PRODUCTS_LiveSearch::Match_B ) works fine.

                you will notice that some of the expressions i tried don't use get value because i also tried passing a single parameter without using the "list" function to see if that helped but to no avail.

                any thoughts about how to format this properly?

                • 5. Re: Passing Multiple Script Parameters (Field Value and Text String)
                  philmodjunk

                  The error message explains the issue. Count only works with direct references to a field or fields. Thus, GetField can't be used as a parameter here.

                  What you can do, is pass the count as the parameter instead of or in addition to the field name.

                  Put Count ( products_PRODUCTS_LiveSearch::Match_B ) as either the parameter or a member of the parameter list and then you can use one script to count values in different fields as controlled by the script parameter expression.

                  • 6. Re: Passing Multiple Script Parameters (Field Value and Text String)
                    johnhorner

                    judging by the speed of your reply, that must have been an obvious alternative, but i would have worked all night re-writing that expression 300 different ways before it would have ocurred to me (if at all) to do it as you suggested.  thank you for giving my evening back to me!!!

                    • 7. Re: Passing Multiple Script Parameters (Field Value and Text String)
                      johnhorner

                      hey philmodjunk, i know you are probably tired of answering questions about script parameters but i have encountered another problem.

                      if, for example, i am passing 4 parameters in a value list and let's say the first field i am passing (the first scrip paramteter) is empty, then what is happening inside the script is that getvalue ( get ( scriptparameter ) ; 1 ) gives me the value of the field that was passed as the 2nd sript parameter, and so on down the line.  such that getvalue ( get ( scriptparameter ) ; 4 ) returns nothing at all.

                      is there a solution to this problem or a workaround that you could suggest?  would the "pipe" method of passing multipe parameters avoid this glitch?  is so, would you be able to outline the method to extract the different parameters... i don't really know much about how to parse text strings like that.  any thoughts would be greatly appreciated.  thanks!

                      • 8. Re: Passing Multiple Script Parameters (Field Value and Text String)
                        Sorbsbuster

                        "the first field I am passing (the first script parameter) is empty"

                        is not the same thing as

                        "the first field I am passing (the first script parameter) is missing".

                        GetValue (Value1 ; value2 ; Value 3 )

                        will not deliver the same parsing as

                        Get Value ( "" ; Value2 ; Value3 )

                        I think.

                        Can you check that you are always passing the same number of values, in the same order, even if one is empty?

                        • 9. Re: Passing Multiple Script Parameters (Field Value and Text String)
                          johnhorner

                          let me try to clarify what i am doing.  i am passig a scrip parameter that looks like this:

                          List (

                               invoices_PRODUCTS_LiveSearch::_kp_ItemCode ;

                               invoices_PRODUCTS_LiveSearch::InventoryRelated_b ;

                               invoices_PRODUCTS_LiveSearch::Qty_In_Stock ;

                               "Invoices_QuickEntry"

                          )


                          the script is being launched by the user clicking on a button that is inside a portal row (the portal is displaying items from the table "invoices_PRODUCTS_LiveSearch".  so as long as the three fields which are being passed as the first three script parameters are not empty, everything works fine.  but if the field which is identified by the third parameter ( invoices_PRODUCTS_LiveSearch::Qty_In_Stock ) is empty, then getvalue ( get ( scriptparameter ) ; 3 ) returns the text string "Invoices_QuickEntry" which was the 4th parameter, and getvalue ( get ( scriptparameter ) ; 4 ) doesn't return anything.  so for some of the items in the portal the script works fine, and for others (without a value in all three fields) it fails.

                          i am not familiar with the format you showed: "getvalue ( value1 ; value2 ; value3 )".  does that return all the values separated by a semi-colon or as repeating fields or something?  i only know how to use getvalue ( valuelist ; 1* ) (* or 2, 3, 4 etc) to get one value at a time.

                          does that help clarify the trouble i am having?

                          UPDATE:

                          it just occurred to me that i may be using the wrong language to describe this.  when i say "third script parameter", perhaps i should be saying the third value in the value list being passed as the script parameter.  does that make more sense?

                          • 10. Re: Passing Multiple Script Parameters (Field Value and Text String)
                            Sorbsbuster

                            "i am not familiar with the format you showed: "getvalue ( value1 ;  value2 ; value3 )" - sorry - my mistake (too late at night) your understanding is correct.  I should have said 'List ("" ; Value2, Value3 )..etc in my example.

                            The terms you used to describe it were spot on - no confusion there.  If it is any consolation, I too would have expected your List and GetValue pairing to work.

                            Try this:

                            List (

                                 invoices_PRODUCTS_LiveSearch::_kp_ItemCode ;

                                 invoices_PRODUCTS_LiveSearch::InventoryRelated_b ;

                                 Case ( invoices_PRODUCTS_LiveSearch::Qty_In_Stock = "" ; "" ; invoices_PRODUCTS_LiveSearch::Qty_In_Stock ) ;

                                 "Invoices_QuickEntry"

                            )

                            If any of the others could be empty then you could add a similar statement to their lines - but you may as well try it with one, on a portal row where only that applies.

                            • 11. Re: Passing Multiple Script Parameters (Field Value and Text String)
                              johnhorner

                              thanks sorbsbuster, i gave your suggestion a shot but, unfortunately, it returns the same result.  i even tried a simplified version.  i passed the following as the script parameter:

                              list (

                                   "" ;

                                   "" ;

                                   "" ;

                                   "Invoices_QuickEntry"

                              )

                              and, unfortuantely, it behaves the same way.  meaning that when i tried to evaluate the 4th parameter i get nothing but if i try to get the first parameter (using getvalue ( get ( scriptparameter ) ; 1 ) )  i get the text string "Invoices_QuickEntry" that was the 4th "value".  i think filemaker just ignores the empty "values" and shifts the others up in the queue.

                              i am going to try passing everything as text strings as follows:

                              List (

                                   "invoices_PRODUCTS_LiveSearch::_kp_ItemCode" ;
                                   "invoices_PRODUCTS_LiveSearch::InventoryRelated_b" ;
                                   "invoices_PRODUCTS_LiveSearch::Qty_In_Stock";
                                   "Invoices_QuickEntry"
                              )

                              and extract using getfield ( getvalue ( get ( scriptparamter ) ; # ) ) instead and see if that helps.

                              i am still curious about how people pass and extract multiple parameters using the "pipe" method if you or anyone uses that technique i would love some information.  thanks again.

                              • 12. Re: Passing Multiple Script Parameters (Field Value and Text String)
                                Sorbsbuster

                                What happens if you make the expression:

                                ist (

                                     invoices_PRODUCTS_LiveSearch::_kp_ItemCode ;

                                     invoices_PRODUCTS_LiveSearch::InventoryRelated_b ;

                                     Case ( invoices_PRODUCTS_LiveSearch::Qty_In_Stock = "" ; "¶" ;  invoices_PRODUCTS_LiveSearch::Qty_In_Stock ) ;

                                     "Invoices_QuickEntry"

                                )

                                ?

                                ------------------------

                                EDIT: tried it - still the (amazing) same result.  But if I change it for

                                Case ( invoices_PRODUCTS_LiveSearch::Qty_In_Stock = "" ; "Is Empty" ;   invoices_PRODUCTS_LiveSearch::Qty_In_Stock )

                                ...for example, it works fine.  You could check for that return in the next step of your script.  Not as I would have expected, by any means.

                                • 13. Re: Passing Multiple Script Parameters (Field Value and Text String)
                                  johnhorner

                                  ahhh... of course!  that's a very good idea.  thanks for pursuing this unusual problem.  in the meantime, i was also able to try passing the parameters (or values) in quotation marks and extracting them with the "getfield" function and that avoids the problem too.  not sure really what the advantages or disadvantages to each method would be, but at least now i have 2 to choose from... much better than none!  thanks!!

                                  • 14. Re: Passing Multiple Script Parameters (Field Value and Text String)
                                    Sorbsbuster

                                    Advantages, to me, of the List ( ; ; )-GetValue ( ; x ) combo is that it is immediately intuitive (present post excepted), and completely scaleable.  I used to use the pipe-passing in the old days, and I wouldn't choose to go back.

                                    1 2 Previous Next