Auto Populate Employee Name field from current user

%3CLINGO-SUB%20id%3D%22lingo-sub-2343687%22%20slang%3D%22en-US%22%3EAuto%20Populate%20Employee%20Name%20field%20from%20current%20user%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2343687%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20SharePoint%20calendar%2C%20I%20need%20when%20the%20user%20creates%20a%20new%20item%20%22Employee%22%20Field%20%7Bcoulmn%20type%20person%20or%20group%7D%26nbsp%3B%20filled%20based%20on%20his%20user%20name.%3C%2FP%3E%3CP%3EAny%20help%20I%20tried%20to%20add%20this%20script%20but%20it%20is%20not%20working.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3CSCRIPT%20src%3D%22https%3A%2F%2Fcode.jquery.com%2Fjquery-1.10.2.min.js%22%20type%3D%22text%2Fjavascript%22%3E%3C%2FSCRIPT%3E%20%20%0A%3CSCRIPT%20src%3D%22https%3A%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fjquery.SPServices%2F2014.02%2Fjquery.SPServices-2014.02.min.js%22%20type%3D%22text%2Fjavascript%22%3E%3C%2FSCRIPT%3E%20%20%0A%3CSCRIPT%20type%3D%22text%2Fjavascript%22%3E%20%20%0A%24(document).ready(function()%20%7B%20%20%0A%20%20%20%20%2F%2F%20get%20the%20title%20of%20current%20user%20%20%0A%20%20%20%20var%20UserName%3D%20%24().SPServices.SPGetCurrentUser(%7B%20%20%0A%20%20%20%20fieldName%3A%20%22Employee%22%2C%20%20%0A%20%20%20%20debug%3A%20false%20%20%0A%7D)%3B%20%20%0A%0A%2F%2Fpopulate%20the%20field%20%22Employee%22with%20the%20current%20account%20%0A%24('textarea%5Btitle%3D%22Employee%22%5D').val(UserName)%3B%20%20%0A%24('input%5Btitle%3D%22Employee%22%5D').val(UserName)%3B%20%20%0A%7D)%3B%20%20%0A%3C%2FSCRIPT%3E%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2343687%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Lists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

I have a SharePoint calendar, I need when the user creates a new item "Employee" Field {coulmn type person or group}  filled based on his user name.

Any help I tried to add this script but it is not working.

 

<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>  
<script type="text/javascript">  
$(document).ready(function() {  
    // get the title of current user  
    var UserName= $().SPServices.SPGetCurrentUser({  
    fieldName: "Employee",  
    debug: false  
});  

//populate the field "Employee"with the current account 
$('textarea[title="Employee"]').val(UserName);  
$('input[title="Employee"]').val(UserName);  
});  
</script> 

 

0 Replies