8 Replies Latest reply on Jan 11, 2012 2:44 PM by RobertA






      Hey Guys!

      I was wondering if i could get a little help with another basic script.

      I am attempting to make a script that is atempting to acheive this goal:

      1) when a checkbox of "Drums" is selected

      2) The "tag number" field changes to the color red.


      here is what i have thus far...

      Set Field [Waste tags::Drum; ValueListItems ( Waste tags::DRUM ; "Drum")]

      If[Waste tags::DRUM = "Drum" ; TextColor (Waste tags::Classification ; RGB ( 255 ; 0 ; 0)) ; " ")]

      end if


      I think that i am using the RGB script incorecctly...

      Thank you all for your help again!!!



        • 1. Re: RBG SCRIPT HELP

          ValueListItems returns a list of all values in the value list you name in the function. It uses this syntax:

          ValueListItems ( "filename" ; "valuelistname" )

          The safest way to use this function is with this syntax: ValueListItems ( get ( FileName ) ; "Yourvaluelistnameinquoteshere" )

          I suspect that the way you have used this function is returning an empty string and that will clear your field of any data as it will assign the empty string to it. Your IF step has incorrect syntax as well.

          Are you trying to add "Drums" to a list of previously selected values in the Waste tags::Drum field?

          If so, you need a different set field expression:

          Set Field [ Waste tags::Drum ; List ( WasteTags::Drum ; "Drum" ) ]

          will do it, but might introduce hidden duplicate copies of "Drum" if that value is already selected.

          Set Field [ Waste tags::Drum ; If ( IsEmpty ( FilterValues ( ValueListItems ( get ( FileName ) ; "NameofYourCheckBoxValueListInQuotes" ) ; "Drum" ) ) ; Waste tags::Drum ; List ( WasteTags::Drum ; "Drum" ) ) ]

          will append "Drum" to the list if it is not already selected in that field.

          And to make the classification field turn red, I'd use a conditional value list instead of the text color function.

          Not IsEmpty ( FilterValues ( ValueListItems ( get ( FileName ) ; "NameofYourCheckBoxValueListInQuotes" ) ; "Drum" ) )

          could be used for that expression.

          • 2. Re: RBG SCRIPT HELP

            Hey Phil,

            Thank you for your promp response!

            I thought I was using the valulistitems script step to tell filemaker that Waste tags::DRUMS was a checkbox...but I now see that my logic is flawed. 

            I also dont understand what you mean by setting the field to a "conditional value list instead of a regular valuelist. 

            here is what i have modified thus far...


            If [ Waste tags::DRUM = "Drum"]

                Set field [ waste tags::Classification; TextColor (Waste tags:: Classification ; RGB (225 ; 0 ; 0 ))

            Else If [ Waste tags::DRUM (does not equal) "Drum"]

                Set Field [Waste tags::Classification; TextColor (Waste tags:: Classification ; RGB (0 : 0: 0 ))

            End If


            I am questioning whether or not my if statment is valid...

            thanks agian!

            • 3. Re: RBG SCRIPT HELP

              If your field is a single value check box (you don't have other checkboxes besides "drum"), it will work.

              Here's a more detailed example of conditional formatting:

              Place Waste tags::Classification on your layout and specify a black text color. While in layout mode, right click it and select conditional formatting.

              (assuming a single value checkbox) Enter:

              Waste tags::DRUM = "Drum"

              as its "formula" and specify a red text color.

              Note, that with existing records in your database where you have used your script to change the color of the actual text, this data level color change will supercede the formatting applied like this to the field at the layout level. If you decide that you prefer conditional formatting, you'll need to use Replace Field Contents with a TextFormatRemove or TextColorRemove function to remove the color formatting applied at the data level.

              • 4. Re: RBG SCRIPT HELP

                Hey phil,

                It makes sense about the conditional formating with the check box. it is indeed a sing valuelisted check box with that value being "drum"

                I have followed your advice and changed the check box to conditional formating and input the script and checked the right boxes in the formula section, but i dont see a script step where you tell filemaker to change the tag number field to red when the drum check box is selected.  i think the way we currently have it set up, they drums field is being changed to red...


                thanks again for your promp responses!


                • 5. Re: RBG SCRIPT HELP

                  There is no script needed with the conditional formatting. That's one of the advantages to using it. The layout where you specify the conditional format should update automatically whenever the value "Drum" is selected in the check box field.

                  Please note the caution about this that I posted in my last response as this will not work with your current data, only new records, unless you first remove the data level color formatting supplied by your script.

                  • 6. Re: RBG SCRIPT HELP

                    Hey Phil,

                    I understand that conditional formating allows you to "script" things without actually creating a script. However, the current way we were just talking about above, the checkbox "drum" text gets changed to red, not the classification field...is there any way that we can add an aditional line to the condital format box and tell it to change the text in the classification box instead?

                    • 7. Re: RBG SCRIPT HELP

                      Set the conditional format expression on the classification field using an expression that checks the value of the drum field. This is what I had in mind why you would specify the "formula" option instead of "value" when setting up the conditional format.

                      • 8. Re: RBG SCRIPT HELP

                        Thank you VERY MUCH Phil!

                        That seems to have worked!!