function "contains" in UI Builder component formula editor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2022 09:17 AM
How do I build a condition in the UI Builder component formula editor to check for a condition 'contains'? Like for below, I want to check if the shortDescription contains 'time sensitive', then return 'High' else return 'Medium'
I checked this article that talks about existing formula editor functions, but I could not find anything that allowed me to do that. Any workarounds/suggestion for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2022 10:01 AM - edited 10-24-2022 10:02 AM
You could use a conditional operator:
//condition ? "True" : "False";
var priority = @STate.shortDescription.indexOf("time sensitive") > -1 ? "High" : "Medium";

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 05:56 AM
I don't think you can use JS operators in the formulas, but you could try indexOf and see if it works. Otherwise you'll probably need to script that property instead of using a formula. When you flip the property to script
you can do something like:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({api, helpers}) {
var answer = "Medium";
if (api.state.shortDescription.toString().toLowerCase().indexOf('time sensitive') > -1) {
answer = "High"
}
return answer;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 06:58 AM
I am trying to do this in the data source configuration pane. I don't have an option to toggle it to a script.
I am assuming I might have to run a page script and set the final value in a state and bind here.