add current loggedin user to watchlist using client script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
THIS ISNOT DISPLAYING IN MY FORM WHY? WHATS THE MISTAKE IN CODE
var watchList=g_form.getValue('watch_list');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Hello @hasthipooji,
The issue is that g_form.getDisplayBox('watch_list').value returns null or undefined, because the Watch list field is not a simple reference field , it’s a Glide List type. The g_form.getDisplayBox('watch_list').value method works with reference fields, not glide lists.
You can fix it by using getDisplayValue() instead.Corrected version of your script:
var watchList = g_form.getValue('watch_list');
var userId = g_user.userID;
// If user not already in watch list
if (!watchList.includes(userId)) {
if (watchList == "") {
g_form.setValue('watch_list', userId);
} else {
g_form.setValue('watch_list', watchList + "," + userId);
}
}
// Wait a bit for the display value to update
setTimeout(function() {
g_form.addInfoMessage("userId of Watch List: " + g_form.getDisplayValue('watch_list'));
}, 1000);
This should correctly display the updated watch list on your form.
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.