3

I'm following this thread which shows how to create a reply to a discussion using REST api. Basically -- created the reply at top level of list, get the reply parent folder, get the FileRef info about the reply, and move the reply under the parent.

That is all working well and the replies appear in the right spot and the parent discussion shows the correct number of replies.

I'm trying to update the Last updated column which has an internal name of DiscussionLastUpdated on the parent so that it can move to the top of our "recent" discussions list. It isn't updating -- neither through the rest calls, nor if I create a child reply through the UI.

I found threads like this which talk about permissions, and I will work on that problem later, but since I am only working with my stuff at the moment AND I am site collection admin with full control over everything....well I don't think that is currently the issue.

After a lot of work I finally found that I can update the Modified date with

var payload = { '__metadata': { "type": _listEntityName },
                DiscussionLastUpdated: new Date().toJSON()
}
return $.ajax({ url: _webUrl + "/_api/web/lists/getbytitle('"+_listName+"')/Items("+itemId+")",
                type: "POST",
                data: JSON.stringify(payload),
                headers:headers.MERGE
})

Even though I'm updating DiscussionLastUpdated, it is the Modified date that is updated.

Does anybody know how to update the Last updated/DiscussionLastUpdated independent of the Modified date?

EDIT: Bonus Question

There is also a LastReplyBy or LastReplyById which I can't seem to set either. There may well be other "rollup-to-the-parent-thread" features that I haven't noticed either. If anyone knows about this in REST or even JSOM please share.

  • First check what type it is, it could be a Computed column (internal type, kinda like a Calculated Column for the end-user) that queries the Modified column(s) – Danny '365CSI' Engelman May 4 '17 at 8:26
  • Well that explains a lot. I checked and Both DiscussionLastUpated and LastReplyBy are Read Only Fields. But that doesn't change that somehow they get updated when using the UI. Any idea how to do that? – Rothrock May 4 '17 at 15:03
  • The the update is done by back-end code, which you cant access or trigger from the front-end – Danny '365CSI' Engelman May 4 '17 at 16:40
  • What happens if you trigger an update of an item, with a workflow or with REST.. write theTitle with the same Title value – Danny '365CSI' Engelman May 4 '17 at 16:52
  • If I update the parent item the modified date changes and the modified by is updated to me. But the DiscussionLastUpdated and LastReplyBy don't. Which is different than how it works when using the UI. – Rothrock May 8 '17 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.