diff --git a/Business Rules/Manipulating system properties values/ScreenShot_0.PNG b/Business Rules/Manipulating system properties values/ScreenShot_0.PNG new file mode 100644 index 0000000000..163c34a9dd Binary files /dev/null and b/Business Rules/Manipulating system properties values/ScreenShot_0.PNG differ diff --git a/Business Rules/Manipulating system properties values/ScreenShot_1.PNG b/Business Rules/Manipulating system properties values/ScreenShot_1.PNG new file mode 100644 index 0000000000..cff25e4c67 Binary files /dev/null and b/Business Rules/Manipulating system properties values/ScreenShot_1.PNG differ diff --git a/Business Rules/Manipulating system properties values/ScreenShot_2.PNG b/Business Rules/Manipulating system properties values/ScreenShot_2.PNG new file mode 100644 index 0000000000..8107615986 Binary files /dev/null and b/Business Rules/Manipulating system properties values/ScreenShot_2.PNG differ diff --git a/Business Rules/Manipulating system properties values/readme.md b/Business Rules/Manipulating system properties values/readme.md new file mode 100644 index 0000000000..f14ed046ee --- /dev/null +++ b/Business Rules/Manipulating system properties values/readme.md @@ -0,0 +1,18 @@ +**Business Rule** + +Script which allows *getting value of specific system property and manipulate these values*. In this example, true/false property is got to determine if script should be executed. Then value of system property which is keeping last created user which gets 'admin' role is updated. + +**Create new system property** + +Before you can get or manipulate custom system property you need to create it in [sys_properties] table. Below you can see example of created property: + +![Creating System Property](ScreenShot_0.PNG) + +**Example configuration of Business Rule** + +![Configuration](ScreenShot_1.PNG) + +**Example execution effect** + + +![Execution effect](ScreenShot_2.PNG) diff --git a/Business Rules/Manipulating system properties values/script.js b/Business Rules/Manipulating system properties values/script.js new file mode 100644 index 0000000000..cab6b7302d --- /dev/null +++ b/Business Rules/Manipulating system properties values/script.js @@ -0,0 +1,21 @@ +(function executeRule(current, previous /*null when async*/ ) { + //Script to read and update specific system properties (in this example to update last created user name with role admin) + + //Get value of property which you would like to verify + var updateAdminUser = gs.getProperty('user.updateNewAdminUsers'); + + //Verify if property is set to true + if (updateAdminUser) { + + //Get property which you would like to update + var property = new GlideRecord('sys_properties'); + property.addQuery('name', 'user.lastCreatedAdmin'); + property.query(); + if (property.next()) { + + //Update value of choosed property + property.value = current.user.getDisplayValue(); + property.update(); + } + } +})(current, previous);