Window.SetCloseTrigger
----------------------

Sets close trigger.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Window](component_Window.md) | [12.1](newinversion121.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "Window.SetCloseTrigger"; Ref; FileName; ScriptName ) 

**MBS**( **"Window.SetCloseTrigger";** /\* Sets close trigger. \*/  
**$Ref**; /\* Pass window or web viewer reference number. \*/   
**$FileName**; /\* The database file name where the script is located.e.g. "test.fmp12" \*/   
**$ScriptName**) /\* The script name.e.g. "MyScript" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Ref | Pass window or web viewer reference number. |  |
| FileName | The database file name where the script is located. | "test.fmp12" |
| ScriptName | The script name. | "MyScript" |

### Result

Returns OK or error.

### Description

Sets close trigger.  
Informs you if a window with a reference closed or a custom web viewer was removed from the layout. FileMaker may rebuild the current layout and delete the custom web viewer.  
  
Parameter to the script is the reference number passed here to identify the object. Please be aware that Window objects are gone when the trigger runs.  
### Examples

Create web viewer and set close trigger:

 Set Variable \[ $$web ; Value: MBS ("[WebView.CreateWithControl](WebViewCreateWithControl.md)"; 0; "placeholder"; 1) \]   
Set Variable \[ $r ; Value: MBS ("Window.SetCloseTrigger"; $$web ; Get(FileName); "Closed") \]  
### See also

- [WebView.Create](WebViewCreate.md)
- [WebView.CreateWithControl](WebViewCreateWithControl.md)
- [Window.ClearCloseTrigger](WindowClearCloseTrigger.md)

### Release notes

- **Version 12.5**
    - Changed custom WebViewer to put it back if FileMaker rebuilds the layout. No longer need [Window.SetCloseTrigger](https://www.mbsplugins.eu/WindowSetCloseTrigger.shtml) to trigger a script to do this.
- **Version 12.1**
    - Added [Window.ClearCloseTrigger](https://www.mbsplugins.eu/WindowClearCloseTrigger.shtml) and [Window.SetCloseTrigger](https://www.mbsplugins.eu/WindowSetCloseTrigger.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 12.5pr2](https://www.mbsplugins.de/archive/2022-10-06/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 12.1](https://www.mbsplugins.de/archive/2022-03-22/New_in_MBS_FileMaker_Plugin_12/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.1pr1](https://www.mbsplugins.de/archive/2022-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 20th January 2022 , last changed 20th January 2022

  
[Window.SetCloseButton](WindowSetCloseButton.md) - [Window.SetCurrentTag](WindowSetCurrentTag.md)

[HTML Version](WindowSetCloseTrigger.shtml)