I have one page layout in which I have placed some fields of content type as label mode, which display the respective value of field while the page is in edit mode.

I want to display the last check in comments in the page, for programmatically getting the comments there is one property SPFileVersion.CheckInComment. But I want to display it in the Page Layout.

I have placed following mark up in Page Layout to get the comments but is not working.

    <th><label id="lblCheckinComment">Comment: </label></th>
    <td><SharePointWebControls:FieldValue FieldName="_CheckinComment" DisableInputFieldLabel="true" runat="server"></SharePointWebControls:FieldValue></td>

How can I get comments?

  • In client browser I can see the value in the field _CheckinComment in FieldValueAsText, but in the same field value is not displayed in FieldValueAsHtml – users1100 Dec 12 '14 at 10:02

Searched over google for hours but not helped. So finally, I went through JavaScript and REST query. So finally, to get the Last Check In comment I needed to modify my code of Page Layout.

The page layout contains below markup:

    <th><label id="lblComment">Comment: &nbsp;</label>  </th>
    <td id="tdCheckInComment"></td>

Create one JavaScript file and give the name whatever you want. In my case, I created GetLastCheckInComment.js.

The JavaScript file contains below code:

window.onload= function(){
    // getting the GUID of list.
    var listGUID = _spPageContextInfo.pageListId;
    // getting the item id
    var itemId = _spPageContextInfo.pageItemId;

    // clearing the value inside the tdCheckInComment
    // checking if list guid found or not.
        //removing {} from the variable.
        listGUID = listGUID.replace(/[{}]/g, "");
        // checkin if item id is found or not.
            var comment = GetLastCheckInComment(listGUID,itemId);
function GetLastCheckInComment(listGUID,itemId) {
    var returnValue;
    try {
            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists(guid'" + listGUID+ "')/items("+itemId+")/File/CheckInComment",
            type: "GET",
            async: false,
            headers: { "Accept": "application/json;odata=verbose" },
            success: function (data, textStatus, xhr) {
                returnValue =data.d.CheckInComment;

            error: function (data, textStatus, xhr) {
                console.error('Error while getting the last check in comment.');
    catch (ex) {
    return returnValue;

Load JavaScript file in the Page Layout. You can give reference of it in <asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">.

And finally I was able to see the last check in comment after the page is loaded.

Hope this helps others too...!!! Thanks.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.