Intermittent issue in Service Portal widget – incorrect “Latest Reply By” user displayed post postin

AviKadam
Giga Contributor

We are facing an intermittent issue in a custom Service Portal Community widget where the UI occasionally displays the wrong user in the “Latest Reply By” section.

 

Scenario

We have a question/article page that shows:

“Latest reply by”

After posting a new reply/comment:

  • sometimes the latest reply to user updates correctly,
  • but on certain records/pages, the UI still shows the previous commenter instead of the newly posted user.

The issue is inconsistent and difficult to reproduce reliably.

 

Current Architecture / Approach

The widget:

  • loads initial question + latest reply data from server,
  • fetches nested replies asynchronously using REST calls,
  • uses spUtil.recordWatch() for live updates,
  • and updates the latest reply object on new comments.

Simplified version of the current logic:

// Initial load
c.latestReply = c.post.latestReply;

Then later during reply to updates:

function placeNewComment(newComment) {
    c.latestReply = newComment;
}

We also use a record watcher similar to:

spUtil.recordWatch(
    $scope,
    "kb_social_qa_answer",
    "question=" + question,
    function(response) {

        if (response.data.action === "entry") {
            getNewReplyDetails(response.data.sys_id);
        }
    }
);

And fetch reply to details asynchronously:

$http.get(apiBaseUrl + resourceUrl)
    .then(function(response) {

        var newComment = response.data.result.data;

        placeNewComment(newComment);
    });

What We Observed

Example:

  • Article A → latest reply to user updates correctly.
  • Article B → after posting a new reply, UI still shows old user as latest reply author.

Same widget/code path, different behavior.

We added temporary logs and observed:

  • initial page load sometimes contains correct latestReply,
  • but occasionally stale/older reply data seems to persist,
  • especially during async/real-time updates.

Questions

Has anyone encountered:

  • stale latestReply values in Service Portal widgets?
  • incorrect realtime updates using spUtil.recordWatch()?
  • race conditions while updating scope objects asynchronously?

Also:

  • is there a recommended pattern for safely maintaining “latest reply” state in AngularJS Service Portal widgets?
  • would deriving the latest reply from the actual comments collection be safer than relying on a cached latestReply object?

Any guidance or similar experiences would be very helpful.

Thanks in advance.

0 REPLIES 0