Plugin.SetErrorScriptTrigger
----------------------------

Sets script to trigger if plugin call returns an error.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Plugin](component_Plugin.md) | [8.5](newinversion85.md) | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes |

MBS( "Plugin.SetErrorScriptTrigger"; FileName; ScriptName ) 

**MBS**( **"Plugin.SetErrorScriptTrigger";** /\* Sets script to trigger if plugin call returns an error. \*/  
**$FileName**; /\* The name of the FileMaker File that contains the script.e.g. "test.fmp12" \*/   
**$ScriptName**) /\* The name of the script to run.e.g. "MyScript" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| FileName | The name of the FileMaker File that contains the script. | "test.fmp12" |
| ScriptName | The name of the script to run. | "MyScript" |

### Result

Returns OK or error.

### Description

Sets script to trigger if plugin call returns an error.  
You can call [Plugin.CallErrorScriptTrigger](PluginCallErrorScriptTrigger.md) to test this.  
The script is called with JSON block as parameter and this JSON includes entries for Function, Parameters, Result, UserName, FileName, ScriptName, AccountName, HostName, RecordID, CurrentTimeStamp, LayoutTableName, LayoutName, WindowName and TraceID.  
  
Please note that this function may trigger scripts at unexpected points, e.g. when a calculation in a layout causes an error. See also [ErrorLog](ErrorLog.md) function.  
  
  
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.  
### See also

- [ErrorLog](ErrorLog.md)
- [Plugin.CallErrorScriptTrigger](PluginCallErrorScriptTrigger.md)

### Release notes

- **Version 8.5**
    - Added [Plugin.CallErrorScriptTrigger](http://www.mbsplugins.eu/PluginCallErrorScriptTrigger.shtml) and [Plugin.SetErrorScriptTrigger](http://www.mbsplugins.eu/PluginSetErrorScriptTrigger.shtml) function.

### Example Databases

- [Utility functions/Trigger Script on Plugin Error](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Trigger%20Script%20on%20Plugin%20Error.shtml#1ScriptAnchor_)

### Blog Entries

- [Watching for Errors with MBS Plugin](https://www.mbsplugins.de/archive/2021-03-18/Watching_for_Errors_with_MBS_P/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 8.5 - Über 5500 Funktionen in einem Plugin](https://www.mbsplugins.de/archive/2018-11-27/Neues_MBS_FileMaker_Plugin_85_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.5 - More than 5500 Functions In One Plugin](https://www.mbsplugins.de/archive/2018-11-27/MBS_FileMaker_Plugin_85_-_More/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2018, Seite 33](https://filemaker-magazin.de/neuigkeit/4025-Appetithappen-FMM_201806)

This function is free to use.

Created 24th October 2018 , last changed 6th September 2022

  
[Plugin.Seats](PluginSeats.md) - [Plugin.SetFunctions](PluginSetFunctions.md)

[HTML Version](PluginSetErrorScriptTrigger.shtml)