3 Replies Latest reply on Nov 23, 2011 10:36 AM by philmodjunk

    Script Trigger in Table view

    Kj

      Title

      Script Trigger in Table view

      Post

      Want a speedy check in/ check out process. Seemed like it would be simple.

      Have 'filter as you type' layout in table view to find records by name. Works. Buttons do not work in table view so I thought I would use script triggers. It is not working. I just want to click on 'checkin' field and have the script set the field to a 'Yes' and set the arrived date and time.

      I can get the checkin field to be a 'yes' but it does not set the date and time. Odd. It is all in the same script. Also, it seems to always think the field is a 'yes' and asks 'do I want to clear the field' (part of script)  when it has not been set to 'yes' yet. 

      By the way, the old way was a form and the button on the field 'check in' worked perfectly.

      Thank you.

      chkin.png

        • 1. Re: Script Trigger in Table view
          philmodjunk

          I'd use list view instead of table view. This, among other things, allows you to use buttons in the record rows. You give up the ability to resize and re-position columns, but I find this is a dangerous option for users to have anyway as you can end up with support calls asking why they can't find needed columns after a user has resized a column so narrow that it is no longer visible.

          However, the script trigger should work. What trigger did you set on the field?

          OnObjectModify should work here, though you don't need the script to set the value to yes, the mouse click on the radio button will do that for you.

          You may also be able to do this without any script. If the "arrived date and time" is the current date and time. Set up those fields to auto-enter the modification date and time respectively (or modification timestamp if you use one timestamp field for both date and time). Then modifying any field in the record will auto-enter the current date and time in those fields without any scripting at all needed.

          Odd. It is all in the same script. Also, it seems to always think the field is a 'yes' and asks 'do I want to clear the field' (part of script)

          You might want to post that script so that we can see what it does.

          To post a script to the forum:

          1. You can upload a screen shot of your script
          2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
          3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
          4. 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 look to your script. (Use the HTML option and paste the text into the HTML editor.)
          • 2. Re: Script Trigger in Table view
            Kj

            Doh!. Yes, the mouse click sets the radio button to yes and then the on object modify trigger script sees that it is yes and asks do you want to clear it? The script trigger works differently than the button performing a script. That means the script trigger did not work on the check in and check out fields at all.

            I now have this as a list view and it is working. 

            Below is the script i used.

            Button: Check In Script Trigger

            If [ Count(Event::${EventID}) < 1 ]

            Show Custom Dialog [ Message: "This person is not registered for Event. You will need to create a registration record before checking in."; Buttons: “OK”, “Cancel” ]

            Halt Script

            End If

            If [ Event::CheckIn = "Yes" ]

            Show Custom Dialog [ Title: "Message"; Message: "Do you want to clear this field?"; Buttons: “No”, “Yes” ]

            If [ Get(LastMessageChoice) = 1 ]

            Halt Script

            End If

            Set Field [ Event::CheckIn; "" ]

            Set Field [ Event::CheckInDate; GetAsDate("")  ]

            Set Field [ Eent::CheckInTime; GetAsTime("")  ]

            Else

            Set Field [ Event::CheckIn; "Yes" ]

            Set Field [ Event::CheckInDate; Get(CurrentDate) ]

            Set Field [ Event::CheckInTime; Get(CurrentTime) ]

            End If

            • 3. Re: Script Trigger in Table view
              philmodjunk

              You can pass the original value of the field as a script parameter for yoru script trigger and then your script can check this value to see if it was yes before you clicked it.

              If [ Get ( ScriptParameter ) = "yes"]