2

Is it possible to have a custom action List Item Menu in a document library on a specific content type, created in SPD 2010?
In code I know is possible, but I'd rather try it out in SP Designer.
Also, is it possible to enable specific security rights during its creation?

3 Answers 3

1

It's definitely possible.

Open the document library in SPD. You will have "Custom Action" button on the ribbon, where you can select "List Item Menu" custom action:

enter image description here

Then, on the form which appears, use vertical scrollbar (many people don't notice it's there) to scroll the contents of the form down. You will see "Rights" box there:

enter image description here

Unfortunately it's just a plain text field, you will get no hints of what should be there. Fortunately I can tell you that :) You must use values of the SPBasePermissions enumeration there. AFAICR, you can define several values, separating them by ",".

Btw, another trick here is that you can use javascript: /* put your js here */ in the "Navigate to URL" box.

Well, as you can see, the interface is not very obvious, but nevertheless it exists :)

3
  • Andrey, thanks a lot! And do you know how I can link it to a specific content type? My document library has 2 content types assigned to it.
    – zora
    Feb 27, 2013 at 12:51
  • This is not possible from SPD :( Feb 27, 2013 at 17:04
  • Thank you Andrey, I needed the confirmation for this. I take the easy approach and create a powershell script for the list item menu. This way I can set the RegistrationType to ContentType and also set the Rights mask in the same time. I'll post it after testing.
    – zora
    Mar 1, 2013 at 9:00
0

In addition to Andrey's answer...

You can use Javascript to find the content type for the selected documents, after the menu item is selected.

Put this in your "Navigate to Url" field in the custom action.

javascript:if (GetListItem('{ListId}', '{ItemId}', function (item) { if (item.get_item("ContentTypeId").get_typeId() == "{YOUR CONTENT TYPE ID}") { doIt(); } }));

and put this function in your master page or a form html webpart on your page

function GetListItem(ListID, ItemID, onSuccess) {

  ExecuteOrDelayUntilScriptLoaded(function () {

    this.context = SP.ClientContext.get_current();
    this.web = this.context.get_web();
    this.list = this.web.get_lists().getById(ListID);

    this.context.load(this.list);

    this.context.executeQueryAsync(Function.createDelegate(this, function onQuerySucceeded(sender, args) {

        this.item = this.list.getItemById(ItemID);
        this.context.load(this.item);

        this.context.executeQueryAsync(Function.createDelegate(this, function onQuerySucceeded(sender, args) {

            onSuccess(this.item);

        }), Function.createDelegate(this, onQueryFailed));
    }), Function.createDelegate(this, onQueryFailed));

 }, 'sp.js');
}

function onQueryFailed(sender, args) {
  alert(args.get_message());
}

then whatever you want to run on a specific content type put in here

function doIt() {
  alert();
}

Tested in SP2010 Foundation.

1
  • Thank you Mike, I'll go with a powershell script for this, since I don't have the rights to change the SharePoint page.
    – zora
    Mar 1, 2013 at 9:06
0

Here are the two solutions, powershell and also VS2010 feature, both tested: http://zoraradosavlevici.wordpress.com/2013/03/01/add-list-item-menu-custom-action-to-a-specific-content-type-sp-2010/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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