I try to manipulated the “EditForm.aspx” of a list in my site collection (SharePoint 2013). I want some input fields to be hidden based on the users permission level. To realize this, I added an editor webpart to the standard form of the EditForm.aspx with the following code:
<script src="https://test-teamshare.zeiss.org/minimal/05011/Libs/jquery-latest.js"></script>
<script src="https://test-teamshare.zeiss.org/minimal/05011/Libs/jquery.SPServices-2013.01.js"></script>
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push("hideInputFields");
function hideInputFields() {
$().SPServices({
operation: "GetRolesAndPermissionsForCurrentUser",
async: false,
completefunc: function(xData, Status) {
var userPerm = $(xData.responseXML).SPFilterNode("Permissions").attr("Value");
var userRole = $(xData.responseXML).SPFilterNode("Role").attr("Name");
if(jQuery(".ms-formbody").find(input[title='Dokumentennummer'])) {
alert("has found the Fiels");
}
if(userRole = "Vollzugriff") {
}
}
});
}
</script>
unfortunately this doesn’t (at least fully) work. The part with the user permission works well, but I am not able to manipulate the input fields.
What am I doing wrong? I tried to replace the “document.ready()” with “_spBodyOnLoadFunctionNames.push()” but this also doesn’t help.
Then I read something about the “Minimal Download Strategy (MDS)” but I don’t really understand that concept based on the information I have about this.
Can anyone help?
Thank your very much
Benjamin
I think the error is in find You use title, you should use ID. Just be careful when the id incudes '$'. Use firebug to see if (jQuery(".ms-formbody").find(input[title='Dokumentennummer'] returns anything.