JS.SetGlobalProperty
--------------------

Sets a global property.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JavaScript](component_JavaScript.md) | [10.0](newinversion100.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JS.SetGlobalProperty"; JSRef; Name; Value ) 

**MBS**( **"JS.SetGlobalProperty";** /\* Sets a global property. \*/  
**$JSRef**; /\* The JavaScript reference number.e.g. $js \*/   
**$Name**; /\* The name of the variable.e.g. "test" \*/   
**$Value**) /\* The JSON value.e.g. "\[1,2,3\]" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| JSRef | The JavaScript reference number. | $js |
| Name | The name of the variable. | "test" |
| Value | The JSON value. | "\[1,2,3\]" |

### Result

Returns OK or error.

### Description

Sets a global property.  
Please pass value as JSON value.  
### Examples

Get and set some properties:

 Set Variable \[ $js ; Value: MBS ( "[JS.New](JSNew.md)" ) \]   
\# try number   
Set Variable \[ $r ; Value: MBS ( "JS.SetGlobalProperty"; $JS ; "v1"; 123 ) \]   
Set Variable \[ $v1 ; Value: MBS ( "[JS.GetGlobalProperty](JSGetGlobalProperty.md)"; $JS ; "v1") \]   
\# try some JSON array   
Set Variable \[ $r ; Value: MBS ( "JS.SetGlobalProperty"; $JS ; "v2"; "\[1,2,3\]" ) \]   
Set Variable \[ $v2 ; Value: MBS ( "[JS.GetGlobalProperty](JSGetGlobalProperty.md)"; $JS ; "v2") \]   
\# try some text   
Set Variable \[ $r ; Value: MBS ( "JS.SetGlobalProperty"; $JS ; "v3"; "\\"test\\"" ) \]   
Set Variable \[ $v3 ; Value: MBS ( "[JS.GetGlobalProperty](JSGetGlobalProperty.md)"; $JS ; "v3") \]   
\# show results   
Show Custom Dialog \[ "Property" ; $v1 &amp; ¶ &amp; $v2 &amp; ¶ &amp; $v3 \]   
Set Variable \[ $r ; Value: MBS ( "[JS.Release](JSRelease.md)"; $JS ) \]  
### See also

- [JS.Evaluate](JSEvaluate.md)
- [JS.EvaluateToString](JSEvaluateToString.md)
- [JS.GetGlobalProperty](JSGetGlobalProperty.md)
- [JS.New](JSNew.md)
- [JS.Release](JSRelease.md)
- [JS.SetGlobalPropertyValue](JSSetGlobalPropertyValue.md)

### Release notes

- **Version 11.3**
    - Changed [JS.CallFunction](https://www.mbsplugins.eu/JSCallFunction.shtml) and [JS.SetGlobalProperty](https://www.mbsplugins.eu/JSSetGlobalProperty.shtml) to not return an error for invalid JSON, but just take it as text for your convenience.

### Example Databases

- [JavaScript/CoordinatDistance](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JavaScript/CoordinatDistance.shtml#4ScriptAnchor_)
- [JavaScript/JavaScript](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JavaScript/JavaScript.shtml#1ScriptAnchor_)

### Blog Entries

- [Custom Functions in JavaScript](https://www.mbsplugins.de/archive/2021-06-14/Custom_Functions_in_JavaScript/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.3pr2](https://www.mbsplugins.de/archive/2021-06-09/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in the MBS FileMaker Plugin 10.0](https://www.mbsplugins.de/archive/2020-01-23/New_in_the_MBS_FileMaker_Plugi/monkeybreadsoftware_blog_filemaker)
- [Our JavaScript engine for FileMaker](https://www.mbsplugins.de/archive/2019-12-09/Our_JavaScript_engine_for_File/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2021, Seite 20](https://filemaker-magazin.de/neuigkeit/4152-Appetithappen-FMM_202104)

This function checks for a license.

Created 7th December 2019 , last changed 29th October 2020

  
[JS.ReleaseAll](JSReleaseAll.md) - [JS.SetGlobalPropertyValue](JSSetGlobalPropertyValue.md)

[HTML Version](JSSetGlobalProperty.shtml)