Phidget.SetScriptTrigger
------------------------

Installs a script trigger with the phidget.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Phidget](component_Phidget.md) | [13.4](newinversion134.md) | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ❌ No |

MBS( "Phidget.SetScriptTrigger"; PhidgetRef; Event; FileName; ScriptName { ; Tag } ) 

**MBS**( **"Phidget.SetScriptTrigger";** /\* Installs a script trigger with the phidget. \*/  
**$PhidgetRef**; /\* The reference number for the phidget.e.g. $phidget \*/   
**$Event**; /\* The name of the event.e.g. "Attach" \*/   
**$FileName**; /\* The file name of the FileMaker database containing the script.e.g. Get(FileName) \*/   
**$ScriptName**; /\* The script name of the script to trigger. \*/   
**$Tag**) /\* Optional; Optional tag value.  
Goes into the JSON passed to the script, so you can pass whatever you like to the script. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PhidgetRef | The reference number for the phidget. | $phidget |  |
| Event | The name of the event. | "Attach" |  |
| FileName | The file name of the FileMaker database containing the script. | Get(FileName) |  |
| ScriptName | The script name of the script to trigger. |  |  |
| Tag | Optional tag value.   Goes into the JSON passed to the script, so you can pass whatever you like to the script. |  | Optional |

### Result

Returns OK or error.

### Description

Installs a script trigger with the phidget.  
Please check phidgets documentation about what events are available for which device.  
The JSON passed to the script will contains an entry for ID with the passed phidget reference number.  
  
Available events:  
| Device Class | Event | Parameters |
|---|---|---|
| All devices | Attach | - |
|  | Detach | - |
|  | PropertyChange | property |
|  | Error | errorString, errorCode |
| Accelerometer | AccelerationChange | timestamp, acceleration |
| BLDCMotor | BrakingStrengthChange | brakingStrength |
|  | PositionChange | position |
|  | VelocityUpdate | velocity |
| CapacitiveTouch | Touch | touchValue |
|  | TouchEnd |  |
| CurrentInput | CurrentChange | current |
| DCMotor | BackEMFChange | backEMF |
|  | BrakingStrengthChange | brakingStrength |
|  | VelocityUpdate | velocity |
| Dictionary | - | - |
| DigitalInput | StateChange | state |
| DigitalOutput | - | - |
| DistanceSensor | DistanceChange | distance |
|  | SonarReflectionsUpdate | count, distances, amplitudes |
| Encoder | PositionChange | positionChange, timeChange, indexTriggered |
| FrequencyCounter | CountChange | counts, timeChange |
|  | FrequencyChange | frequency |
| GPS | HeadingChange | heading, velocity |
|  | PositionChange | latitude, longitude, altitude |
|  | PositionFixStateChange | positionFixState |
| Gyroscope | AngularRateUpdate | timestamp, angularRate |
| Hub | - | - |
| HumiditySensor. | HumidityChange | humidity |
| IR | Code | code, bitcount, isRepeat |
|  | Learn | code, codeInfo |
|  | RawData | data, dataLen |
| LCD | - | - |
| LightSensor | IlluminanceChange | illuminance |
| Magnetometer | MagneticFieldChange | timestamp, magneticField |
| MotorPositionController | PositionChange | position |
|  | DutyCycleUpdate | dutyCycle |
| PHSensor | PHChange | ph |
| PowerGuard | - | - |
| PressureSensor | PressureChange | pressure |
| RCServo | PositionChange | position |
|  | TargetPositionReached | position |
|  | VelocityChange | velocity |
| ResistanceInput | ResistanceChange | resistance |
| RFID | Tag | tag, protocool |
|  | TagLost | tag, protocool |
| SoundSensor | SPLChange | dB, dBA, dBC, octaves |
| Spatial | AlgorithmData | timestamp, quaternion |
|  | SpatialData | timestamp, acceleration, angularRate, magneticField |
| Stepper | PositionChange | position |
|  | Stopped | - |
|  | VelocityChange | velocity |
| TemperatureSensor | TemperatureChange | temperature |
| VoltageInput | SensorChange | sensorValue, sensorUnit |
|  | VoltageChange | voltage |
| VoltageOutput | - | - |
| VoltageRatioInput | SensorChange | sensorValue, sensorUnit |
|  | VoltageChange | voltageRatio |

  
We queue triggers and fire them when FileMaker is not busy. If the device sends too many events, we may discard in-between ones and only deliver the last event. This way you can process measurements as fast as you can, but we don't overload FileMaker.  
  
  
With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.  
  
Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.  
### Examples

Set attach and detach script triggers:

 Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $$phidget ; "Attach"; Get(FileName); "Attached" ) \]   
Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $$phidget ; "Detach"; Get(FileName); "Detached" ) \]  
Set trigger for temperature changing

 Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "DataInterval"; 1000 ) \]   
Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "TemperatureChangeTrigger"; ,1 ) \]   
Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $phidget ; "TemperatureChange"; Get(FileName); "TemperatureChange" ) \]  
Set IlluminanceChange trigger:

 Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "DataInterval"; 2000 ) \]   
Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "IlluminanceChangeTrigger"; 10 ) \]   
Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $phidget ; "IlluminanceChange"; Get(FileName); "IlluminanceChange" ) \]  
Set HumidityChange trigger:

 Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "DataInterval"; 2000 ) \]   
Set Variable \[ $r ; Value: MBS ( "[Phidget.SetProperty](PhidgetSetProperty.md)"; $phidget ; "HumidityChangeTrigger"; 1 ) \]   
Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $phidget ; "HumidityChange"; Get(FileName); "HumidityChange" ) \]  
Set triggers for RFID:

 Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $phidget ; "Tag"; Get(FileName); "TagFound" ) \]  
Set Variable \[ $r ; Value: MBS ( "Phidget.SetScriptTrigger"; $phidget ; "TagLost"; Get(FileName); "TagLost" ) \]  
### See also

- [Phidget.ClearScriptTrigger](PhidgetClearScriptTrigger.md)
- [Phidget.SetProperty](PhidgetSetProperty.md)

### Example Databases

- [Phidgets/Phidget Barometer](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Barometer.shtml#2ScriptAnchor_)
- [Phidgets/Phidget Digital Outputs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Digital%20Outputs.shtml#2ScriptAnchor_)
- [Phidgets/Phidget Distance Sensor](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Distance%20Sensor.shtml#2ScriptAnchor_)
- [Phidgets/Phidget IR Receiver](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20IR%20Receiver.shtml#2ScriptAnchor_)
- [Phidgets/Phidget LCD](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20LCD.shtml#2ScriptAnchor_)
- [Phidgets/Phidget Light Sensor](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Light%20Sensor.shtml#2ScriptAnchor_)
- [Phidgets/Phidget Temperator Sensor](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Temperator%20Sensor.shtml#2ScriptAnchor_)
- [Phidgets/Phidget Voltage Input](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Phidgets/Phidget%20Voltage%20Input.shtml#2ScriptAnchor_)

### Blog Entries

- [Using the RFID reader from Phidgets in FileMaker](https://www.mbsplugins.de/archive/2025-09-18/Using_the_RFID_reader_from_Phi/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 10 - Phidgets](https://www.mbsplugins.de/archive/2023-12-10/MBS_Plugin_Advent_calendar_10_/monkeybreadsoftware_blog_filemaker)
- [News in MBS FileMaker Plugin 13.4](https://www.mbsplugins.de/archive/2023-09-20/News_in_MBS_FileMaker_Plugin_1/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 16th August 2023 , last changed 16th September 2025

  
[Phidget.SetProperty](PhidgetSetProperty.md) - [Phidget.SetTag](PhidgetSetTag.md)

[HTML Version](PhidgetSetScriptTrigger.shtml)