Skip to content

Commit bf446c6

Browse files
authored
Create readme.md
1 parent 76f58bb commit bf446c6

File tree

1 file changed

+29
-0
lines changed
  • UX Data Broker Transform/create-update-user-preference

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Create/Update User Preference Data Broker
2+
3+
This repository provides a data broker for creating or updating user preferences in ServiceNow. The broker allows you to specify a preference name and value, storing or updating it in the user’s preferences.
4+
5+
## Features
6+
7+
- **Create or Update User Preferences**: Provides a simple interface for adding or modifying preferences by name and value.
8+
- **Error Handling**: Logs errors if the preference name is missing or if an unexpected issue arises.
9+
10+
## Template Overview
11+
12+
```javascript
13+
/**
14+
* This data broker creates or updates a user preference of the given name with the given value
15+
* @param {{name: string, value?: string}} inputs inputs from the properties field above
16+
*/
17+
function transform({ name, value }) {
18+
const lib = "Data Broker";
19+
const func = "Create Update User Preference";
20+
try {
21+
if (!name) throw new Error("Missing required param 'name'");
22+
23+
gs.getUser().savePreference(name, value);
24+
} catch (e) {
25+
gs.error(`${lib} ${func} - ${e}`);
26+
throw new Error(e);
27+
}
28+
}
29+
```

0 commit comments

Comments
 (0)