Display Business Rules Equivalent for Widgets on Portals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 07:04 AM
Hello friends! 🙂
How would you massage data (on the server side) from a table before handing it over to widgets used on a portal or before sending it as a response from (an out of the box) REST API?
On forms, I use display business rules to massage content from a specific table and field before it's sent to the front end. I use this to mask some data on the fly, for example.
Unfortunately the display business rules are bypassed by widgets and REST API calls.
How can I achieve this for the service portal widgets and the (out of the box) REST APIs?
Modifying the widgets and writing custom scripted APIs to wrap the out of the box rest api would work, but these are terrible solutions. There must be a better and generic way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 09:02 AM
May be you want to create a new field and use before BR to update the value for reading purpose. or you might want to use calculated field type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 09:39 AM
Thanks Sunil.
The output from the display rule varies depending on the user (or a parameter in the API call). For example, for some users, I want to mask all credit card information, for others, I want to mask just the expiry date.
If this was a knowledge article, I would want to modify the title of the article for some users, but not to others.
I'll explore the calculated field possibility.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2024 06:43 PM
The appropriate solution woulbe writing a before query BR, based on the role of logged in user.
if(gs.getUser().hasRole("")){
currrent.credit_card_number = masked_num;
}
Mark this is helpful if you find!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2024 04:17 AM
Hello Sunil,
This won't work. As per the docs, a before query br can modify the query, but won't parse and modify a value that is yet to be retrieved from the db. I also tested this, just in case 🙂
So far:
Only a display business rule successfully modifies a field on its way to the user (e.g. in a larger string, mask only the appearance of a credit card number, but leave the rest of the text as is) - but the problem is the display business rules don't run for widgets/api.