Business Rule to update category
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 10:43 AM - edited ‎06-18-2024 10:44 AM
I have the below business rule that updates Category in the RITM based on a variable. The script below works fine when the user language is English. However, for users who have French set as lamguage, a new choice appears (in red) instead of selecting from the existing selection (in green). How can this be resolved?
(function executeRule(current, previous /*null when async*/ ) {
var category = current.variables.category.getDisplayValue();
if ((current.u_category == '')){
current.u_category = category;
}
})(current, previous);
//u_category is a string field with Choice in sys_choice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 11:31 AM
You can try to use one of the lines below. You need to get the internal value that is used in the database instead of the display value.
#1
var category = current.getValue("category")
#2
var category = current.variables.category
#3
var category = current.category

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 12:13 PM
Hi @tsoct ,
current.variables.category fetches the internal value of the category variable directly, so you should update the same.
Please try the below script-
(function executeRule(current, previous /*null when async*/ ) {
var category = current.variables.category; // Using the variable value directly
if (category && current.u_category == '') {
current.u_category = category; // Setting the internal value directly
}
})(current, previous);
If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!
Thanks & Regards,
Sanjay Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 08:48 PM
Hello @Community Alums ,
Instead of category label, it return sys_id like below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2024 09:58 PM
Hi @tsoct,
Consider using toSting() method which will help you get the actual value
var categoryValue = current.variables.category.toString();