Geoff Varosky
–   Geoff Varosky MCP, MCTS
–   Senior Solutions Developer for Grace-Hunt, LLC.
–   Company: http://www.grace-hunt.com
–  ...
– What are Custom Actions?
– Demonstrations
   • Creating a Simple Custom Action
   • Creating a Slightly More Complex Cus...
Per Microsoft –

“A custom action represents a link, toolbar button, menu item, or
  any control that can be added to a to...
What does that mean?
– Custom Actions can be bound to List Types
   • A Custom Action can be bound to a Document Library, ...
What does that mean?
– Custom Actions can be bound to File Types
   • Example: ‘Edit in Microsoft Word’ bound to Word (.do...
What does that mean?
– Custom Actions can be bound to Content Types
   • Example: Folders, Document Content Types, List Co...
Examples of Custom Actions
   • Edit Control Block (ECB Menu)
Examples of Custom Actions
   • Edit Control Block (ECB Menu)
   • Toolbars
Examples of Custom Actions
   • Edit Control Block (ECB Menu)
   • Toolbars
   • Site Actions Menu
Examples of Custom Actions
   •   Edit Control Block (ECB Menu)
   •   Toolbars
   •   Site Actions Menu
   •   Site Setti...
Examples of Custom Actions
   •   Edit Control Block (ECB Menu)
   •   Toolbars
   •   Site Actions Menu
   •   Site Setti...
Examples of Custom Actions
   •   Edit Control Block (ECB Menu)
   •   Toolbars
   •   Site Actions Menu
   •   Site Setti...
Examples of Custom Actions
   •   Edit Control Block (ECB Menu)
   •   Toolbars
   •   Site Actions Menu
   •   Site Setti...
Examples of Custom Actions
   •   Edit Control Block (ECB Menu)
   •   Toolbars
   •   Site Actions Menu
   •   Site Setti...
But wait, there’s more!
– Create links to pages that really should be there…
   • Example: There is a link to the Site Col...
…and more
– Custom Actions can also be hidden
   • Example: You do not want site administrators to be able to delete
     ...
– Notepad!
– What do I use?
   • Visual Studio 2005/2008
   • Andrew Connell’s SharePoint Project Utility for Visual Studi...
Creating a Simple
 Custom Action
Feature Definition (feature.xml)
Scope

– Web
    – A “sub-site”
    – Only activates the feature on the specific web
– Site
    – Site Collection
    – Ap...
Element Manifest (manifest.xml)
<CustomAction
      ContentTypeId = quot;Textquot;
      ControlAssembly = quot;Textquot;
      ControlClass = quot;Textqu...
Id (optional)
– Specifies a unique identifier for custom action
– May be a GUID or a unique term
– Example: DeleteWeb

Gro...
Location (optional)
– Specifies the location for this custom action
– Example: Microsoft.SharePoint.SiteSettings

Registra...
RegistrationId (optional)
– Specifies the registration attachment for a per-item action
– Example (List Identifier – Task ...
Sequence (optional)
– The order in which your action will appear.
– If not specified, displayed in the order it is read by...
Permissions
– RequireSiteAdministrator (optional)
   – Boolean (True or False)
   – Cannot be used on ECB menu list items
...
UrlAction Tokens
– ~site
    – References the current SPWeb context
– ~sitecollection
    – References the current SPSite ...
UrlAction Tokens
– {ListId}
    – GUID representation of the list
– {SiteUrl}
    – References the URL of the SPWeb contex...
Creating a Slightly More
Complex Custom Action
Hiding Custom Actions
Custom Action Groups
– My Blog
   • http://gvaro.spaces.live.com

– GraceHunt.SharePoint CodePlex Projects
   • http://codeplex.com/GraceHunt

...
– MSDN
   • Custom Action Definitions
        – http://snipurl.com/d8zi7
    • Default Custom Action Locations and IDs
   ...
Q&A
–   Geoff Varosky MCP, MCTS
–   Senior Solutions Developer for Grace-Hunt, LLC.
–   Company: http://www.grace-hunt.com
–  ...
Upcoming SlideShare
Loading in …5
×

Introduction To Developing Custom Actions Within SharePoint

17,663 views

Published on

Presentation delivered at SharePoint Saturday in Boston on 3/14/09

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
17,663
On SlideShare
0
From Embeds
0
Number of Embeds
275
Actions
Shares
0
Downloads
1
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide
  • Thank you for your time today.<Introductions>
  • Hidden=trueActivate and deactivate via CMD line – why? You do not want site admins, who you are hiding this from, to be able to deactivate the feature to delete the site!stsadm -o activatefeature -name SPS.HideCustomAction -url http://spsaturday.litwareinc.com
  • Record questions – post answers on my blog following SharePoint Saturday
  • Introduction To Developing Custom Actions Within SharePoint

    1. 1. Geoff Varosky
    2. 2. – Geoff Varosky MCP, MCTS – Senior Solutions Developer for Grace-Hunt, LLC. – Company: http://www.grace-hunt.com – Blog: http://gvaro.spaces.live.com – Email: gvarosky@grace-hunt.com – Twitter: @gvaro
    3. 3. – What are Custom Actions? – Demonstrations • Creating a Simple Custom Action • Creating a Slightly More Complex Custom Action • Hiding Custom Actions • Custom Action Groups – References – Q&A
    4. 4. Per Microsoft – “A custom action represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that a user sees. Custom actions can be bound to list type, content type, file type, or programmatic identifier (ProgID).” Source: http://snipurl.com/d8y70
    5. 5. What does that mean? – Custom Actions can be bound to List Types • A Custom Action can be bound to a Document Library, but, may not be bound to a Task List – Example: Check In/Check Out
    6. 6. What does that mean? – Custom Actions can be bound to File Types • Example: ‘Edit in Microsoft Word’ bound to Word (.doc, .docx, etc.) Document Content Types
    7. 7. What does that mean? – Custom Actions can be bound to Content Types • Example: Folders, Document Content Types, List Content Types, etc. – Programmatic Identifiers • Example: Task List Identifier (107)
    8. 8. Examples of Custom Actions • Edit Control Block (ECB Menu)
    9. 9. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars
    10. 10. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu
    11. 11. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu • Site Settings Page
    12. 12. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu • Site Settings Page • Central Administration Pages – Operations, Application Management
    13. 13. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu • Site Settings Page • Central Administration Pages – Operations, Application Management • Shared Service Provider Pages
    14. 14. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu • Site Settings Page • Central Administration Pages – Operations, Application Management • Shared Service Provider Pages • You get the idea…
    15. 15. Examples of Custom Actions • Edit Control Block (ECB Menu) • Toolbars • Site Actions Menu • Site Settings Page • Central Administration Pages – Operations, Application Management • Shared Service Provider Pages • You get the idea… (hopefully?)
    16. 16. But wait, there’s more! – Create links to pages that really should be there… • Example: There is a link to the Site Collection Recycle Bin on the Site Settings page, however, there is no link to the current site Recycle Bin. (Why? Who knows…) Never fear though – you can add one easily (Demo #1) – Custom Actions can pass along information to act upon • Example: Add a “Complete Task” action to an Edit Control Block, which calls an ASPX page, taking the parameters of the List ID and Item ID, and updating the task item within a list. (Demo #2)
    17. 17. …and more – Custom Actions can also be hidden • Example: You do not want site administrators to be able to delete their sites by using the Delete This Site link on the Site Settings page – so, we can remove it by using HideCustomAction (Demo #3) – Create Groupings of Custom Actions by using CustomActionGroup • Example: Create a grouping of your Custom Actions on the Site Settings page for all of your Custom Actions… (Demo #4)
    18. 18. – Notepad! – What do I use? • Visual Studio 2005/2008 • Andrew Connell’s SharePoint Project Utility for Visual Studio – http://snipurl.com/d8yv9 • WSPBuilder – http://snipurl.com/d8yxv
    19. 19. Creating a Simple Custom Action
    20. 20. Feature Definition (feature.xml)
    21. 21. Scope – Web – A “sub-site” – Only activates the feature on the specific web – Site – Site Collection – Applies to all webs within the site collection – Web Application – Applies to all site collections and webs within a web application – Farm – Applies to all web applications, site collections, etc.....
    22. 22. Element Manifest (manifest.xml)
    23. 23. <CustomAction ContentTypeId = quot;Textquot; ControlAssembly = quot;Textquot; ControlClass = quot;Textquot; ControlSrc = quot;Textquot; Description = quot;Textquot; GroupId = quot;Textquot; Id = quot;Textquot; ImageUrl = quot;Textquot; Location = quot;Textquot; RegistrationId = quot;Textquot; RegistrationType = quot;Textquot; RequireSiteAdministrator = quot;TRUEquot; | quot;FALSEquot; Rights = quot;Textquot; Sequence = quot;Integerquot; ShowInLists = quot;TRUEquot; | quot;FALSEquot; ShowInReadOnlyContentTypes = quot;TRUEquot; | quot;FALSEquot; ShowInSealedContentTypes = quot;TRUEquot; | quot;FALSEquot; Title = quot;Textquot;> </CustomAction>
    24. 24. Id (optional) – Specifies a unique identifier for custom action – May be a GUID or a unique term – Example: DeleteWeb GroupID (optional) – Identifies the unique group that this element is contained in – Example: SiteAdministration
    25. 25. Location (optional) – Specifies the location for this custom action – Example: Microsoft.SharePoint.SiteSettings RegistrationType (optional) – Specifies the list, item content type, file type, or programmatic identifier that this action is associated with – Example: List
    26. 26. RegistrationId (optional) – Specifies the registration attachment for a per-item action – Example (List Identifier – Task List): 107 Title (required) – Specifies the name of your action – Example: DeleteWeb Description (optional) – Longer description for action which is shown as a tooltip or sub- description (where applicable) for the action
    27. 27. Sequence (optional) – The order in which your action will appear. – If not specified, displayed in the order it is read by SharePoint by Feature and by order in element listing (XML).
    28. 28. Permissions – RequireSiteAdministrator (optional) – Boolean (True or False) – Cannot be used on ECB menu list items – Rights – Specify rights needed for this Custom Action to be visible – Example: “ApproveItems,DeleteListItems” – Possible Values http://snipurl.com/d8z2l
    29. 29. UrlAction Tokens – ~site – References the current SPWeb context – ~sitecollection – References the current SPSite context – {ItemId} – GUID of the item action is called from – {ItemUrl} – URL of the item the action is called from
    30. 30. UrlAction Tokens – {ListId} – GUID representation of the list – {SiteUrl} – References the URL of the SPWeb context the action is called from – {RecurrenceId} – Unsupported in context menus – Source URL – This token is not available, but there is a way to get it via JavaScript, which we will see in Demo #2 – http://snipurl.com/d8zb6
    31. 31. Creating a Slightly More Complex Custom Action
    32. 32. Hiding Custom Actions
    33. 33. Custom Action Groups
    34. 34. – My Blog • http://gvaro.spaces.live.com – GraceHunt.SharePoint CodePlex Projects • http://codeplex.com/GraceHunt – John Holliday’s Custom Action Resources • Hiding Custom Actions, and a Utility to get all custom action identifiers http://snipurl.com/d8zea
    35. 35. – MSDN • Custom Action Definitions – http://snipurl.com/d8zi7 • Default Custom Action Locations and IDs – http://snipurl.com/d8zka • How to: Add Custom Actions to the User Interface – http://snipurl.com/d8zq2 • CustomAction Element – http://snipurl.com/d9jd4 • CustomActionGroup Element – http://snipurl.com/d9jfx • HideCustomAction Element – http://snipurl.com/d9jhs
    36. 36. Q&A
    37. 37. – Geoff Varosky MCP, MCTS – Senior Solutions Developer for Grace-Hunt, LLC. – Company: http://www.grace-hunt.com – Blog: http://gvaro.spaces.live.com – Email: gvarosky@grace-hunt.com – Twitter: @gvaro

    ×