2 Replies Latest reply on Jun 29, 2013 12:13 AM by paul350passaic

    Scrip Trigger for Drop down menu

    paul350passaic

      Title

      Scrip Trigger for Drop down menu

      Post

           Hi, Im new in filemaker and scripting. Im using filemaker pro 12. Im trying to set up a timesheet for my small office. I have 4 fields involved. TimeIn, TimeOut, DayType and Hours Total. I manage to set all field right except for DayType.  I set up a drop down field for DayType where user can select if the day is regular, holiday, sick day, vacation, and hopping it would trigger or autopopulate the TotalHours with the corresponding value for each DayType.

           Regular is (nothing since the value will come from the calculation of TimeIn and TimeOut

           Holiday is 8.00 hours

           etc...

           I used a trigger for the dropdown:

           OnObjectSave:

           if[MyLayout::DayType = "Holiday"]

           insert Text [Select; MyLayout::TotalHours; "8.00"]

           End If

            

           but its giving me an error saying that the TotalHours field is not modifiable. Im not sure what to check whether TotalHours is locked or has any kind of restriction. Im thinking since my TotalHours has a "calculation" value, its not accepting the script trigger.

            

           pls help. Thanks!

        • 1. Re: Scrip Trigger for Drop down menu
          philmodjunk

               Correct. Fields of type calculation cannot be modified. You can't click in the field and edit the data and a script can't use an "insert" type step nor can you use the better option of using set field to modify the field.

               You might be able to change your calculation field into a number field with an auto-entered calculation that then permits direct edits, but I'd just change the calculation field's calculation and get rid of the script and script trigger as it is unecessary.

               Make your new calculation something like this:

               Case ( MyLayout::DayType = "Holiday" ; 8 ;
                           Mylayout::DayType = "sick day" ; //put value or calculation for sick day here
                           Mylayout::DayType = "vacation" ; //put value or calculation for vacation here
                           Mylayout::DayType = "regular" ; //put the calculation that you already have in the field here )

               You may also want to set up an auto-enter setting that enters "regular" into DayType so that it's the default value in each newly created record.

          • 2. Re: Scrip Trigger for Drop down menu
            paul350passaic

                 Works perfectly! and you just answered my next question about "regular" Thanks again :)