
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2021 09:24 AM
We looking to gain a better understanding around UI Builder. One of the features we want to better understand is the "Edit scripted property value". The documentation seems pretty light out in the docs site and community around this. Anyone have some guidance on how we can learn more about this feature? How would we know what values to script to?
@Brad Tilton
Solved! Go to Solution.
- 4,308 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2021 07:02 AM
This basically lets you access page parameters, client state variables, data resources, etc., and use that data to set a value on whichever component property you're scripting.
In this blog post, I demo how you might use this to make a dynamic filter on a list component: https://developer.servicenow.com/blog.do?p=/post/quebec-ui-builder-lists/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2021 04:58 AM
Very good question!
"Stylized text" component has 3 properties: text, tag and css. All the properties can be configured by either direct text value, dynamic data binding or scripted property value. By click on "Edit text CSS" one can set the following CSS rule for example:
h2 {
color: blue;
}
It will change the color of the text:
On the other side, css property can be changes via dynamic data binding or scripted property value too:
or using more JavaScript object destructuring (see here😞
/**
* @param {params} params
* @param {api} params.api
* @param {any} params.imports
*/
function evaluateProperty({api: {context: {session: {user}}}}) {
const color = user.roles.includes("itil") ? "red" : "blue";
return "h2 { color: " + color + "; }";
}
As the result the CSS will be red for ITIL users:
In the same way, one can define new client state variable, like validationError, and to set the style to "red" if state scripted property value
return `h2 { color: ${api.state.validationError? "red" : "black" } }`;
One can set the state variable dynamically inside of client script:
api.setState("validationError", false);
As the result the style of text will be changes dynamically from client script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2021 07:02 AM
This basically lets you access page parameters, client state variables, data resources, etc., and use that data to set a value on whichever component property you're scripting.
In this blog post, I demo how you might use this to make a dynamic filter on a list component: https://developer.servicenow.com/blog.do?p=/post/quebec-ui-builder-lists/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2021 01:05 PM
thanks