locked
MOSS 2007 Custom Action {URLAction} element RRS feed

  • Question

  • Hi Experts,
    I am trying to add a custom action with the urlaction added with tokens.
    From here: http://blogit.create.pt/blogs/andrevala/archive/2008/08/11/SharePoint-2007-Deployment_3A00_-Custom-Action-Features.aspx

    I found out about adding the {listid} etc., however, I would like to find out if there is a way to get the folder location in a document library. Something like in the snippet below:

    <!-- Document Library Toolbar Upload Menu Dropdown -->

      <CustomAction Id="UserInterfaceCustomActions.DocLibUploadToolbar"

        RegistrationType="List"

        RegistrationId="101"

        GroupId="UploadMenu"

        Rights="ManagePermissions"

        Location="Microsoft.SharePoint.StandardMenu"

        Sequence="1000"

        Title="MY DOCLIB UPLOAD MENU TOOLBAR BUTTON">

        <UrlAction Url="/_layouts/CustomActionsHello.aspx?ListId={ListId}&FolderName={FolderName}"/>

      </CustomAction>

    So by using the upload menu and select custom action "MY DOCLIB UPLOAD MENU TOOLBAR BUTTON" to bring me to http://moss/doclib/CustomActionsHello.aspx?ListId={GUID}&FolderName=Folder1


    Many thanks in advance!
    Tuesday, August 11, 2009 5:33 AM

Answers

  • I dont think you can do that - but you can easily check in your custom ASPX what the referrer URL was - and from that get the folder.
    Ishai Sagi, MCTS in SharePoint Development (WSS & MOSS) Read my blog! http://www.sharepoint-tips.com
    • Proposed as answer by Peter Holpar Wednesday, August 12, 2009 6:46 AM
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:15 AM
    Wednesday, August 12, 2009 6:07 AM
  • Hi,

    You can try to use Request.ServerVariables["HTTP_REFERER"], but reading this tread and the linked articles (Request.UrlReferrer is always null, http://forums.asp.net/t/1101617.aspx) both method may be problematic. Do you have HTTPS or proxy between the client and SharePoint?

    Peter
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:15 AM
    Wednesday, August 12, 2009 12:50 PM
  • Hi,

    Could not you rework your custom action to be applied to the folder content type instead? Then you could use the ItemId token too.
    See the article Sample CustomActions for SharePoint (http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx) for an example to define custom action for content type, and use 0x0120 as RegistrationId (content type id for folder).

    Peter
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:16 AM
    Wednesday, August 12, 2009 1:03 PM

All replies

  • I dont think you can do that - but you can easily check in your custom ASPX what the referrer URL was - and from that get the folder.
    Ishai Sagi, MCTS in SharePoint Development (WSS & MOSS) Read my blog! http://www.sharepoint-tips.com
    • Proposed as answer by Peter Holpar Wednesday, August 12, 2009 6:46 AM
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:15 AM
    Wednesday, August 12, 2009 6:07 AM
  • Hi,
    Thanks for your help!
    I added the following to the CustomActionsHello.aspx to get the urlreferrer
    string urlrefer = "nothing";
      if(Request.UrlReferrer != null) 
      {
        urlrefer = Request.UrlReferrer.ToString(); 
      }
    however, the UrlReferrer is always null whenever I click on the custom action "MY DOCLIB UPLOAD MENU TOOLBAR BUTTON" which redirects me to the CustomActionsHello.aspx page
    Am I missing something?

    Thanks again!
    Wednesday, August 12, 2009 10:49 AM
  • Hi,

    You can try to use Request.ServerVariables["HTTP_REFERER"], but reading this tread and the linked articles (Request.UrlReferrer is always null, http://forums.asp.net/t/1101617.aspx) both method may be problematic. Do you have HTTPS or proxy between the client and SharePoint?

    Peter
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:15 AM
    Wednesday, August 12, 2009 12:50 PM
  • Hi,

    Could not you rework your custom action to be applied to the folder content type instead? Then you could use the ItemId token too.
    See the article Sample CustomActions for SharePoint (http://blog.thekid.me.uk/archive/2007/06/23/sample-editcontrolblock-customaction-for-sharepoint.aspx) for an example to define custom action for content type, and use 0x0120 as RegistrationId (content type id for folder).

    Peter
    • Marked as answer by Chengyi Wu Tuesday, August 18, 2009 3:16 AM
    Wednesday, August 12, 2009 1:03 PM