Monday, May 28, 2007

Meanings of variables in the context menu's script

If you are building a web part that displays context menus for list items - just like the context menus that SharePoint builds out of the box, you need to know the meaning of the attributes that you need to add to the table that holds the item. I couldn't find any documentation or referance to it on the internet, so I decided to publish the results of my diggings.
If you look at the source html of the built-in web part,you will see that every item with a context menu looks like this:

<table height="100%" cellspacing="0" class="ms-unselectedtitle" onmouseover="OnItem(this)" id="1"
icon="icdocx.gif|Microsoft Office Word|SharePoint.OpenDocuments"

The question is asked - what do those attribute mean? what is "cout" and what is "otype"? what values are expected there?

After some research, here is my dictionary:

  • ctxname: Name of the context object on the page that holds the context for the list that you are connecting to.
  • url: link to the document (can be either relative or absolute.
  • dref:File Directory Referance - the relative folder path the item\document is in. For example if I have a document library called "documents" with the url "http://portal/documents", the items in the root folder will have "documents" as the dref value, while items in a folder called "test" will have "documents\test".
  • perm: has to do with permissions, but I didn't figure out how it works yet.
  • type: Seems not to be used for items - but to create menu seperators or different kind of menus.
  • ext: The document extension. For example "doc", "docx", "ppt" and so on.
  • icon: This seems to control the "edit" menu item. Here you specify the icon that will be displayed next to the "edit in..." menu item, the text that will appear as the name of the application (edit in Microsoft Word) and the script that will be used to edit the item (I have no idea what possible values can be used here). All of this seperated by the "|" character.
  • otype: Current Item FSObj Type. This seems to have something to do with the check in-check out menus, that will not be displayed if this is 1, but I could not figure out what is the logic here.
  • COUId: Current Item Checked Out User Id. (ID of the user in the web site the item is from)
  • sred: Server File Redirect. Allows you to specify a URL that will be used instead of the file's url when the link is clicked or when a menu option is used. For example, if you put a link to another document, all menu actions will be redirected to that document instead.
  • cout: Current Item Checkedout To Local. If the item is checked out to a local (offline) folder and not to the database. 0 for false, 1 for true.
  • hcd: Controls if a menu item to navigate to the "/_layouts/updatecopies.aspx" will be added. I am guessing this has to do with records management (update copies of the document when it was changed).
  • csrc: Copy source link. If the item is a copy of an item in a records management site, this holds the link to the source, and adds the menu item for going to the source file (Go to source).
  • ms: Current Item Moderation Status. Also has to do with if its checked out or not, and if its draft or not.
  • ctype: The type of the item. I could not find where that is used.
  • cid: Content Type ID. The ID of the content type for the item. also seems to be used for list menus to determine the content type to create when a user clicks on the new item menu.
  • uis: Current Item UI String. Seems to hold the version number, where the major version is a multiplication of 512, and the minor version is the reminder (the script gets the minor version number by doing "%512"). For example, a value of 512 is version 1.0 while 513 is version 1.1 and 1024 is version 2. Does this mean we have a version limit of 511 minor versions in sharepoint? According to the "introduction to versioning", this is only the default and the administrator can change this. This sounds fishy considering the "512" limit is hard coded in the javascript.
  • surl: Source Url. This dictates where the page will go back to after a menu item is clicked.


Robin Meuré said...

Nice work mate! Always usefull this type of information :)

Unknown said...

Simply Brilliant!!!! Really simplified my work.