0

I have a Yes/No check box built in on the new item form in custom list.

Is there any way to derive information who updated this check box (other than versioning)?

I would be interested in getting a person's name displayed below this check box as "Updated by".

I'd appreciate your help.

Thanks!

4
  • 1
    Can't you can get the value of Modified By field?
    – users1100
    Dec 6, 2017 at 12:00
  • That's the thing: "Modified By" relates to changes of the entire new item form. Whoever modifies anything else on the form will be reflected in "Modified By" field and I need to get this information for this particular field only and keep it not overridden. :(
    – Nicollum
    Dec 6, 2017 at 12:17
  • how about replacing the 1 check box with a 1 people picker and 1 date field and ask users to fill their name/date in as you need to keep track of it. (as an alternative idea)
    – Chris G
    Dec 6, 2017 at 14:33
  • So that's the tricky part, this needs to be a system output (similarly to field: Created By or Modified By). I already have a field who should tick off this check box. I need a sort of a automated proof who actually did it (audit purposes). Time stamp is irrelevant. As there are always multiple people updating the list items, each time any of the other fields is updated, the "Modified By" gets overriden. And basically, any of the fields can be changed back and forth.
    – Nicollum
    Dec 6, 2017 at 14:55

2 Answers 2

1

Check the example below:

1.Create a custom list with Yes/No Column "YesNoColumn" and single line of text column "Updated by".

2.Add code below into a script editor web part in new form page.

<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () { 
    $("input[title='Updated by']").val(getUserName());
    $("input[title='Updated by']").attr("readonly","true").css('background-color','#F6F6F6');
});
function getUserName(){
    var username;
    var userid = _spPageContextInfo.userId;
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        async: false,
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            username=data.d.Title;
        },
        error: function () {            
        }
    });
    return username;
}
</script>

3.Add the code below into script editor web part in Edit form page.

<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var fieldValue=$("input[title='YesNoColumn']").is(":checked");
    var updatedby=$("input[title='Updated by']").val();
    $("input[title='Updated by']").attr("readonly","true").css('background-color','#F6F6F6');
    $("input[title='YesNoColumn']").change(function(){
        if($(this).is(":checked")!=fieldValue){
            $("input[title='Updated by']").val(getUserName());
        }else{
            $("input[title='Updated by']").val(updatedby);
        }
    });
});
function getUserName(){
    var username;
    var userid = _spPageContextInfo.userId;
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        async: false,
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            username=data.d.Title;
        },
        error: function () {            
        }
    });
    return username;
}
</script>

enter image description here

2
  • Excellent article, that worked for me, thanks a lot.
    – mdevm
    Aug 10, 2018 at 18:21
  • is there anyway we can also show timestamp next to 'app' in Updated by field. Please advise.
    – mdevm
    Aug 14, 2018 at 16:39
0

I am not providing the code, but if you have just basic knowledge of Jquery then you would be able to do it by following steps.

  1. Change the SharePoint UI to classic mode.
  2. Create a supportive field which will store the name of the user who made changes to the check box.
  3. Create a JS file and reference JQuery into it.
  4. In Document.Ready() function, you have to write the checked change event on the field.
  5. Get the id of checkbox field, get it by developer tools in Chrome/IE to bind the event.
  6. In check changed event you have to set the field value to current logged in user's display name.
  7. To get the current user's display name, you can use _spPageContextInfo.userDisplayName
  8. Save the file to one of the document library and add the script editor web part on the new/edit form of the list.
  9. Give the URL of the file which you stored and check the output.

I hope this would help you to get the name of the user who checked/unchecked the checkbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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