Copy HRBP field values in Customer WatchList using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-28-2023 04:17 AM - edited ‎08-28-2023 04:22 AM
Hi Community,
Hope you all are doing great.
I am facing issue while coping the values from HRBP field to Customer Watchlist.
HRBP is also a list collector field.
1.Issue using BR
if the customer watchlist is blank, it will not coping the values from HRBP field.
There is one BR also running which is adding Customer watchlist automatically for few particular HR service. In this condition when I am adding HRBP it is coping all the values in Customer watchlist.
Before, Insert/Update
Condition active is True AND HRBP is changes
Script -
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var arr = current.watch_list.split(',');
var watchList = current.watch_list;
var hrbp = current.u_hrbp;
var arr2 = hrbp.split(',');
gs.info("harsha arr" + arr);
for (var i = 0; i < arr2.length; i++) {
if (watchList.indexOf(arr2[i]) == -1) {
gs.info("harsha arr" + arr);
arr.push(arr2[i]);
}
}
current.watch_list = arr.join();
})(current, previous);
2.Issue using Client script.
And in the Client Script it is Coping all the values from HBBP field, But after saving the form it is setting only one user. Here that another one BR is overriding.
Script-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2023 01:39 AM
Hi @Harsha1 ,
Please try with below updated BR and Client Script:
Business Rule:
(function executeRule(current, previous /*null when async*/) {
var arr = current.watch_list ? current.watch_list.split(',') : [];
var hrbp = current.u_hrbp;
var arr2 = hrbp.split(',');
for (var i = 0; i < arr2.length; i++) {
if (arr.indexOf(arr2[i]) == -1) {
arr.push(arr2[i]);
}
}
current.watch_list = arr.join();
})(current, previous);
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var hrbp = g_form.getValue('u_hrbp');
var watchList = g_form.getValue('watch_list');
var hrService = g_form.getValue('hr_service');
if (hrService == "4d52355f871fa11027cb65373cbb353f" || hrService == "282c18021b97e1945ed35533604bcba9" || /* ...other conditions... */) {
var arrlist = watchList ? watchList.split(",") : [];
arrlist.push(hrbp);
g_form.setValue("watch_list", arrlist.join());
}
}
Thanks,
Ratnakar