1

I am trying to implement a simple solution to support short URLs on SharePoint 2010. The idea is to make use of the document id(I guess, it should not cause any performance impact) and allow the users to grab the URL from the ECB menu(with custom action item).

Eg:
The url of the document is ../_layouts/DocIdRedir.aspx?ID=DEMODOC-7-1

Custom Action

<CustomAction
    Description="Gets the Shorten URL"
    Id="ECBItem"
  RegistrationType="List"
  RegistrationId="101"
  ImageUrl="/_layouts/1033/Images/RTEDCELL.GIF"
  Location="EditControlBlock"
  Sequence="1000"
  Title="Short Link" >
    <UrlAction
        Url="javascript:(function () { var o = { url:'{SiteUrl}/_layouts/shortenURL/shortURL.aspx?List={ListId}&ID={ItemId}', title: 'Short URL', allowMaximize: true, showClose: true, width: 300, height: 200 }; SP.UI.ModalDialog.showModalDialog(o); }) ();"
        />
</CustomAction>

Is there an easy to get the document ID (like ListId, ItemId...) instead of using listitem.Properties["_dlc_DocId"].ToString() method.

  • 2
    I think the only way you can get doc id in custom action is using client api: where you async get the list item and then get doc id: item.get_item('_dlc_DocId'). For example like in this article blog.frederikprijck.net/2011/12/05/… – Andrey Ungur Jul 25 '14 at 8:25

Your Answer

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

Browse other questions tagged or ask your own question.