I want to disable the fields based upon the current login in user RRS feed

  • Question

  • In my edit form, I have an 3 different  Assigned To people picker field, what I want to do is to compare the current user to the Assigned To field, if they are the same, disable some fields else some them
    Wednesday, March 22, 2017 5:47 AM

All replies

  • You can use given below JavaScript code to get the current login user. If your doing code on Edit form. and using jQuery featch the AssignedTo field Value :


    For PeoplePicker field try this : $("input[Title='FieldName']").val()

    Wednesday, March 22, 2017 7:30 AM
  • Hi 

    i tried above code its not working,it would be helpful if you elaborate in detail

    Thursday, March 23, 2017 11:55 AM
  • Can you add your steps of doing it ?? then I'll explain it to you.
    Sunday, March 26, 2017 8:09 PM
  • Hi,

    The following code for your reference, add modify the code and add it into script editor web part in edit form page.

    I create a custom list with 3 people picker fields(AssignedTo1,AssignedTo2,AssignedTo3) and a single line of text field(Field1). If 3 people picker fields contains current user, hide the Field1.

    <script src="//" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {	
    	var currentUserId=_spPageContextInfo.userId;
    		var obj=$.parseJSON($(this).val());
    		for(var i=0;i<obj.length;i++){
    			var userId=obj[i].EntityData.SPUserID;
    				//hide some fields
    				$(".ms-standardheader nobr:contains('Field1')").closest("tr").hide();

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Tuesday, March 28, 2017 3:11 AM