Skip to content

Commit 6441237

Browse files
authored
Adding a Business Rule, which allows getting and manipulating system properties (#255)
* Adding a Business Rule, which allows manipulating system properties * Create readme.md * Add images to readme * Add relative images links to readme
1 parent b076983 commit 6441237

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed
38.7 KB
Loading
69.2 KB
Loading
37 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
**Business Rule**
2+
3+
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.
4+
5+
**Create new system property**
6+
7+
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:
8+
9+
![Creating System Property](ScreenShot_0.PNG)
10+
11+
**Example configuration of Business Rule**
12+
13+
![Configuration](ScreenShot_1.PNG)
14+
15+
**Example execution effect**
16+
17+
18+
![Execution effect](ScreenShot_2.PNG)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
//Script to read and update specific system properties (in this example to update last created user name with role admin)
3+
4+
//Get value of property which you would like to verify
5+
var updateAdminUser = gs.getProperty('user.updateNewAdminUsers');
6+
7+
//Verify if property is set to true
8+
if (updateAdminUser) {
9+
10+
//Get property which you would like to update
11+
var property = new GlideRecord('sys_properties');
12+
property.addQuery('name', 'user.lastCreatedAdmin');
13+
property.query();
14+
if (property.next()) {
15+
16+
//Update value of choosed property
17+
property.value = current.user.getDisplayValue();
18+
property.update();
19+
}
20+
}
21+
})(current, previous);

0 commit comments

Comments
 (0)