1 Reply Latest reply on Mar 14, 2016 11:19 PM by bigtom

    I am trying to create a script to select an Entity from a list and then list all the incidents relating to the Entity and then list and count the occurrences of a specific incident (incident category) related to that Entity and also provide the number of

    Leebc

      Hi I'm new to Filemaker,

       

      Hopefully someone can help me stop pulling my hair out.

      I am trying to create a script to select an Entity from a list and then list all the incidents relating to the Entity and then list and count the occurrences of a specific incident (incident category) related to that Entity and also provide the number of occurrences for that Incident.

       

      This is what I have done so far but I'm sure I'm missing something and there is a much easier way to do it. I would like to use the script repetitively for other searches.

       

      ------------------------------------------------------------------------------------------------------------------------------------------------------

       

      Set Variable [$IncidentReaction; value: 0]

      Set Variable [$EntityName; value: Get (ScriptParameter)]

      Set Variable [$Encounters; value:0]

       

      Set Error Capture [On]

      Perform Find [Incident::Entity: [$EntityName]

      If [not Get (FoundCount)………

      …………..

       

      Set field [Incidents::gEncounters; Get (FoundCount)]

      Set Variable [$IncidentReaction; Get (FoundCount)]

      Set Variable [$IncidentReactionCount; Get (foundCount)]

      Got to Record [First]

       

      Loop

                      If [$IncidentReactionCount > 0]

                                      If [Incident::Reaction  = “Yes”]

                                             Set Variable [$IncidentReaction; $IncidentReaction +1]

                                             Set Variable [$IncidentReactionCount; $IncidentReactionCount -1]

                                             Go to Record [Next; Exit after last]

                                  Else

                                        Set Variable [$IncidentReactionCount; $IncidentReactionCount -1]

                                        Go to Record [Next; Exit after last]

      End if

                 End if

      End Loop

      Set Field [Incidents::gIncidentReactions; ($IncidentReaction)]

      Exit Script []