0

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.

  • I have 2010, so I can't check this for 2007. But I have the option to replace permissions versus add permissions. Adding wouldn't take away contribute permissions whereas replace would. Secondly, I work with SPServices a lot and I'm unaware of any outstanding bugs. – Erin L Jul 14 '16 at 14:15
  • @ErinL , in 2007 I grant and delete. But delete does not remove the Author's ability to later edit the form it created. I tried getting hacky with SPGetCurrentUser and then using the same code Ive used previously to hide the fields, but SPGetCurrentUser is not returning a string for Title or Name. – Adam Raetz Jul 14 '16 at 14:25
  • What versions of JQuery and SPServices are you using? – Erin L Jul 14 '16 at 14:32
  • @ErinL SPServices 2014.02 and jQuery 1.11.3 – Adam Raetz Jul 14 '16 at 14:35
  • Are you using a third party tool, or building a Visual Studio workflow? All the articles I'm finding state that 2007 doesn't have Grant Permissions OOTB. – Erin L Jul 14 '16 at 18:22
0

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.

  • Progress! I'm at least getting undefined on my alert now. – Adam Raetz Jul 14 '16 at 14:53
  • From inside the EditForm.aspx? – Erin L Jul 14 '16 at 15:28
  • I just added a couple fields that seem to make a difference for my code depending on whether I'm in a SharePoint page or a SharePoint dialog – Erin L Jul 14 '16 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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