Skip to content

Commit 76f58bb

Browse files
authored
Create create-update-user-preference.js
Added the code for a transform data broker that creates or updates the current user's sys_user_preference
1 parent 3ae1cc4 commit 76f58bb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* This data broker creates or updates a user preference of the given name with the given value
3+
* @param {{name: string, value?: string}} inputs inputs from the properties field above
4+
*/
5+
function transform({ name, value }) {
6+
const lib = "Data Broker";
7+
const func = "Create/Update User Preference";
8+
try {
9+
if (!name) throw new Error("Missing required param 'name'");
10+
11+
12+
gs.getUser().savePreference(name, value);
13+
} catch (e) {
14+
gs.error(`${lib} ${func} - ${e}`);
15+
throw new Error(e);
16+
}
17+
}
18+
19+
/**
20+
* Make sure to select that this data broker mutates data
21+
* Input this in the properties field:
22+
*
23+
[
24+
{
25+
"name": "name",
26+
"label": "Name",
27+
"description": "The name of the user preference to create or update",
28+
"readOnly": false,
29+
"fieldType": "string",
30+
"mandatory": true,
31+
"defaultValue": ""
32+
},
33+
{
34+
"name": "value",
35+
"label": "Value",
36+
"description": "The value to store in the user preference",
37+
"readOnly": false,
38+
"fieldType": "string",
39+
"mandatory": false,
40+
"defaultValue": ""
41+
}
42+
]
43+
*/

0 commit comments

Comments
 (0)