only last comment should be displayed in work notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 02:03 AM
Only last comment should be displayed to the Requester in work notes field (A separate field on request to store the last comments) Other Activity should not be displayed.
I have below requirement where i shouldn't allow requester not to see the activity filter or other activity on request.
for this i have created a field called last comment and written below scripts.
Created a display business rule which fills a scratchpad value with the last comment.
function(current) {
g_scratchpad.lastWorknote = current.work_notes.getJournalEntry(1); })(current);
And a onload Client script:
if (g_scratchpad.lastWorknote){g_form.setValue('u_last_worknote', g_scratchpad.lastWorknote);}
I'm not able to hide activities filtered or activity log for the requester. please can someone help me how to hide activity log and display last comment field on the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 03:28 AM
Seems complex. Why not just make a BR that updates the last work notes when work_notes are added?
If work_notes changes -> current.u_last_worknote = current.work_notes; //(add .getJournalEntry(1); if needed)
Test as a "before update" BR and see if you can copy the work_notes to the new field without any issues
You don't want to use current.update() as that could create a loop where it tries to update the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2023 03:38 AM
Actually my concern is to hide activity log for the requester and need to show only the last updated comment to the requester. do you have any idea..? for the same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 12:14 PM
Not really. You could create a onLoad client script (isolated field set to false) which would loop through the HTML and hide the cards other than the first one based on the classes.
I made a quick example which doesn't differentiate between comments and work_notes, but might give you an idea. Basically it searches for the li elements in the activity log and then loops through the divs inside them for sn-widget-textblock class. It skips over the first one and hides the rest.
function onLoad() {
var listCards = document.querySelectorAll('li.h-card');
var firstFound = false;
for (var i = 0; i < listCards.length; i++) {
var textBlock = listCards[i].querySelectorAll('div.sn-widget-textblock');
if (textBlock.length > 0) {
if (firstFound) {
listCards[i].style.display = 'none';
} else {
firstFound = true;
}
}
}
}
Of course this doesn't prevent visibility fully. They might still be able to see the worknotes before the page has properly loaded and it's not exactly super hard to block. But since the requestor can always see the last comment it doesn't exactly matter if they, for a short time, see the old comments as well untill the script loads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 10:14 PM
this is not working for me. do you have any other solution.