Menu.SetScriptAction
--------------------

Sets which script is called if a menu item in this menu is selected.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Menu](component_Menu.md) | [4.1](newinversion41.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "Menu.SetScriptAction"; menu; FileName; ScriptName { ; ScriptParameter } ) 

**MBS**( **"Menu.SetScriptAction";** /\* Sets which script is called if a menu item in this menu is selected. \*/  
**$menu**; /\* The reference to the menu. Please create one with [Menu.CreateMenu](MenuCreateMenu.md). \*/   
**$FileName**; /\* The filename of file which contains the script.e.g. "Menus.fmp12" \*/   
**$ScriptName**; /\* The name of the script.e.g. "MenuScript" \*/   
**$ScriptParameter**) /\* Optional; If you want a specific script parameter.  
Default is to leave empty and get the ID fo the menu item. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| menu | The reference to the menu. Please create one with [Menu.CreateMenu](MenuCreateMenu.md). | $menu |  |
| FileName | The filename of file which contains the script. | "Menus.fmp12" |  |
| ScriptName | The name of the script. | "MenuScript" |  |
| ScriptParameter | If you want a specific script parameter.   Default is to leave empty and get the ID fo the menu item. |  | Optional |

### Result

Returns OK or error.

### Description

Sets which script is called if a menu item in this menu is selected.  
You can use [MenuItem.SetScriptAction](MenuItemSetScriptAction.md) to associate a script with individual items or use this function for a whole menu.  
See also [Menu.GetScriptFileName](MenuGetScriptFileName.md) and [Menu.GetScriptName](MenuGetScriptName.md).  
The script parameter is the MenuItem reference, so you can use functions like [MenuItem.GetTitle](MenuItemGetTitle.md) to get the title or [MenuItem.GetTag](MenuItemGetTag.md) to get an associated value.  
  
  
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

- [Menu.CreateMenu](MenuCreateMenu.md)
- [Menu.GetScriptFileName](MenuGetScriptFileName.md)
- [Menu.GetScriptName](MenuGetScriptName.md)
- [MenuItem.GetTag](MenuItemGetTag.md)
- [MenuItem.GetTitle](MenuItemGetTitle.md)
- [MenuItem.SetScriptAction](MenuItemSetScriptAction.md)

### Example Databases

- [Menu/Popup Menu](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Menu/Popup%20Menu.shtml#2ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 5.5pr4](https://www.mbsplugins.de/archive/2015-12-28/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 27th January 2016

  
[Menu.SetMinimumWidth](MenuSetMinimumWidth.md) - [Menu.SetShowsStateColumn](MenuSetShowsStateColumn.md)

[HTML Version](MenuSetScriptAction.shtml)