Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

up vote 0 down vote accepted

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/

share|improve this answer
add comment

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.

share|improve this answer
    
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 '13 at 9:06
add comment

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 :)

share|improve this answer
    
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 '13 at 12:51
    
This is not possible from SPD :( –  Andrey Markeev Feb 27 '13 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 '13 at 9:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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