Search code examples
filemaker

Filemaker value list - default value for each layout


I have a question regarding value lists in Filemaker. I have a value list called "eventtype" inside, I have 3 values. Now, those values are being shown in a field "eventtype". But due to the nature of my app, I need to separate those 3 events and make a layout for each of them. I would like to have the field "event type" fulfilled upon entering the Card layout for each of those 3 events. For example, I would like to report an alarm, upon entering the "CARD new alarm" I would like to have the value of "event type" already fulfilled with the value "Alarm". Same goes for other 2 event types and their respective layouts. Now, can this be done ? Or should I separate those values and create new fields in my table ? - But that would complicate things, since I need to show all of those events on my main layout under a field "event type". Can that field then show the data from other 3 fields ?

sorry if this is too long, let me know if I can explain it better.


Solution

  • IMHO, the simplest solution is to place three buttons in your popover, each calling the same script with a different parameter.

    Then your script would be something like:

    If [ Get (ScriptParameter) = "Alarm"]
      New Window [ Style: Card; Using layout: “CARD new alarm” ]  
      New Record
      Set Field [ Events::EventType; "Alarm" ]
    Else If [  Get (ScriptParameter) = "Foo"  
      New Window [ Style: Card; Using layout: “CARD new foo” ]  
      New Record
      Set Field [ Events::EventType; "Foo" ]
    Else If [  Get (ScriptParameter) = "Bar"  
      New Window [ Style: Card; Using layout: “CARD new bar” ]  
      New Record
      Set Field [ Events::EventType; "Bar" ]
    End If 
    

    Or perhaps more succinctly:

    If [ Get (ScriptParameter) = "Alarm"]
      New Window [ Style: Card; Using layout: “CARD new alarm” ]  
    Else If [  Get (ScriptParameter) = "Foo"  
      New Window [ Style: Card; Using layout: “CARD new foo” ]  
    Else If [  Get (ScriptParameter) = "Bar"  
      New Window [ Style: Card; Using layout: “CARD new bar” ]  
    End If
    New Record
    Set Field [ Events::EventType; Get (ScriptParameter) ]