11 Replies Latest reply on Jun 11, 2015 12:52 PM by tays01s

    Toggle button

    tays01s

      Title

      Toggle button

      Post

      I'm using a button in a portal row to change the value of a field between 0 and 1. However, I find that the script written causes every row to change:

      Perform Script [ “Select Activity_date_activities” ]

      Set Field [ Activity_dates::Add_date; Case( Activity_dates::Add_date=1;0; Activity_dates::Add_date=0;1
      )]

      I've tried using an 'if' in the script to ensure it only acts on the selected row (

      Perform Script [ “Select Activity_date_activities” ] ) but that didn't work.

       

       

        • 1. Re: Toggle button
          SteveMartino

          Seems odd.  Are you sure the button is completely contained in one row? Try dragging it completely out of the portal, then back in.

          Also, maybe put in go to field, or go to object (name field in portal w/inspector) script step as the first step to make sure it is going to the right field on the right portal row.

           

           

          • 2. Re: Toggle button
            philmodjunk

            Set field only changes the value of one field of one record each time that it executes so it is not clear how what you have posted could possibly change the value of more than one record.

            Perform Script on the other hand performs the script identified for it to run in the script step. So what does "Select Activity_date_activities" do?

            You can, BTW, set up a single value check box with a value list of 1 to get nearly the same result you are attempting with a button and scripts. You can use a value list with just the number 1 as the single custom value defined in the value list and resize the checkbox formatted field to show only the check box. Clicking the check box enters a 1, clicking it again clears the field. This assumes that you can treat an empty field as the value zero, which is often possible.

            • 3. Re: Toggle button
              symbister

              any chance that the field is defined with global storage?

              • 4. Re: Toggle button
                tays01s

                I agree, it should work and in fact did work until I tweaked something else! I cannot figure out what.

                The button is definitely in the row and not set to global storage.

                "Select Activity_date_activities" is a script I use to select the date and thereby set the related records in the next portal 'downstream'. To be honest it shouldn't be necessary and was really to reassure me that I really was dealing only with a single portal row.

                While I continue to search for the cause of this problem, can you let me know about this single value checkbox? Do you mean I should use a field with a single value, value list of 1? I would like the field to have a value of 0 or 1, not 1 or blank.

                • 5. Re: Toggle button
                  philmodjunk

                  Yes, the value list would have just one custom value, the number 1. As noted, this is only an option if you can work with no value in place of a zero value.

                  You can also set up a button to perform this set field script step:

                  Set Field [YourTable::ToggleField ; Not YourTable::ToggleField ]

                  That step will change 0 to 1 and 1 to 0 when executed.

                  I'd check two things in your current design:

                  If you are using FileMaker 12 or newer, enter find mode and drag the portal a few pixels. If the field doesn't move with the portal, it's not correctly "owned" by the portal object. Drag the field away from the portal, release the mouse and then carefully drag it back. Move the portal again to check.

                  Regardless of version, check the table occurrence reference for the field. Select the field and check to see what text appears to the left of :: in the Display Data From box on the Inspector's data tab. This should be the same as what you have specified in Show Related Records From in portal set up for your portal, or, in some cases, it can be from a table occurrence related to that of the portal's but then what relationship you have defined can make a difference.

                  • 6. Re: Toggle button
                    tays01s

                    I should be shot! I'd conditionally formatted the toggle button to change colour on changing value. I had updated all the field references but NOT the conditional formatting formula. It now works.

                    Thanks.

                    • 7. Re: Toggle button
                      philmodjunk

                      As "Forum Community Leader", I hereby extend you a permanent "Stay of Execution"! wink

                      • 8. Re: Toggle button
                        butcombepete

                        I am having the same problem and cannot seem to fix:

                        portal on which I want to have multiple toggle boxes that toggle between 1 & 0 - setting a button on a portal row to perform a script like 

                        set field (mytable::field ; not mytable::field) results in the top portal row changing whichever portal row button is clicked 

                        what i am looking for is a portal with multiple boolean toggle boxes along a line I need 1 or 0 entered, because for parsing purposes I need an entry of some sort. I can make things work by making the field a radio button, but that requires two blobs for every entry in the portal row which is too cumbersome - if I show a single check box then that appears to work, but actually the field then gets a repeat entry when the check box is changed:

                        field is set to auto enter 0; click once & then field goes to 1; click again and the field might go to 0 return 1

                        I can see this because if the portal entries list (mytable::field) shows more entries than there should be: say there have been two portal lines entered list might produces 1,0,0,1

                        i'm baffled

                         

                         

                         

                        • 9. Re: Toggle button
                          tays01s

                          Well, I'm v. much at the bottom of the dog pile re. expertise, but this is what worked for me:

                          Field labels 'Vomit' on top of 'GRV' and grouped as a button.

                          'Vomit' has the script 'Vomit/GRV hide' while 'GRV' has the script 'Vomit/GRV show'.

                          Conditional format formula for 'Vomit': IsEmpty(IO 2::Vomit_n) produces 'no fill' colour. The 'Vomit_n' field has 'hide object when' $$vomit=0.

                          'Vomit_GRV' field has an autoenter data value of '0' whereas 'Vomit_n' field has no autoenter.

                          See scripts below, hope this helps:

                          Misc: vomit/grv_hide

                          Set Variable [ $$vomit; Value:0 ]

                          Commit Records/Requests [ No dialog ]

                          Refresh Window

                          Misc: vomit/grv_show

                          Set Variable [ $$vomit; Value:1 ]

                          Commit Records/Requests [ No dialog ]

                          Refresh Window

                          • 10. Re: Toggle button
                            butcombepete

                            Thanks Stephen, I have managed a work around in a similar way to the one that you suggested. However what i haven't managed to do is but a button on a portal row which activates a script that then acts on that specific portal row - never mind - work around appears to work. smiley

                            • 11. Re: Toggle button
                              tays01s

                              I may be mistaking your meaning, but could you not just draw a rectangle/ other shape in the row, alongside your fields and choose a script trigger? I've used this method to select specific rows to pull up related records 'downstream' or as a simple 'delete row' script to get rid of that particular record.