I have been editing the editform.aspx for a list I manage. I used some jquery and javascript in order to hide certain fields.

However there comes a point in my workflow where I need to disable the Author's permissions to the item and leave them with Read only permissions. I tried doing this in the workflow within SPD, but it does not hold.

I cannot figure out any method of scraping for the current user to check if they are the author; wherein I would then hide the fields from them.

I tried working with SPServices but I believe there is an outstanding bug with it.

I'm not even certain how to attack this issue now. If only the workflow would actually do what it says it will: "Grant Read permission to current item for item:CreatedBy".

UPDATE: I found another version of ErinL's solution below. It works perfect for my situation and allowed me to find The Current User. I then compared the current user to the Created By user and hid fields on the form based on that comparison. The code for the function that worked for SP2007, and the jquery and SPServices mentioned in the comments is:

        $().SPServices({
        operation: "GetUserInfo",
        async: false,
        userLoginName: $().SPServices.SPGetCurrentUser(),
        completefunc: function (xData, Status) {
            $(xData.responseXML).find("User").each(function() {
                curUserId = $(this).attr("ID");
                curUserName = $(this).attr("Name");
                curFullUserName = $(this).attr("ID")+";#"+$(this).attr("Name");
             });
        }
    });

A BIG thanks to ErinL for getting my thoughts going the right direction.

有帮助吗?

解决方案

In SPServices 2013.01 and up, you need to include the webURL property.

$(document).ready( function(){
    var user = $().SPServices.SPGetCurrentUser({
        webURL: "http://sharepoint/site/",
        fieldName: "Title",
        fieldNames: {},
        debug: false
    });
    alert(user);
});

EDIT Added fieldsNames and debug properties to SPGetCurrentUser function.

许可以下: CC-BY-SA归因
scroll top