Posts RSS Comments RSS 16 Posts and 26 Comments till now

Archive for June, 2008

Sharepoint Drop Down Context Menu Workflow Shortcut

It’s fairly simple to add custom menu options to the drop down context menu in sharepoint library/list views.  One useful example maybe to provide a shortcut to start workflows, instead of opening the workflow page; selecting the desired workflow and clicking the Start button.

To do this we need to add some Javascript to the page.  Edit the page and add a Content Editor Web Part, hide it by clearing its Layout / Visible on Page checkbox.  Edit the Content Editor Web Part Source and insert the following Javascript:


<script language="javascript">

function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Send for Review";
var strAction = "http://sharepointserver/Workflows/Send%20for%20Review/Send%20for%20Review.aspx?List=14987b66-90be-4693-aafd-94bc6ba8f18e&amp;amp;ID=24&amp;amp;TemplateID={dcbbce95-46dc-4b58-b69e-a99b9ea6a698}&amp;amp;Source=http%3A%2F%2Fsharepoint%2Edomain%2Ecom%2FWIP%2FForms%2FOpen%2Easpx%3FPageView%3DShared";

var strImagePath = "";

var start = strAction.indexOf("&amp;amp;ID=")+4
var prefix = strAction.substr(0, start)
var suffix = strAction.substr(strAction.indexOf("&amp;amp;", start), strAction.length)

strAction = "location.href = '" + prefix + currentItemID + suffix + "'"

// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);

// add a separator to the menu
CAMSep(m);

return false;
}
</script>

If you update the workflow you will need to edit the strAction property as the URL will change. Also if you try to start a workflow using the shortcut on an item where the workflow is already running the workflow will error. If there is a way to check if workflow is running on an item I’d be interested to know how it’s done!

Microsoft SQL Server Data Services

Microsoft‟s Data Platform vision meets the needs of the evolving data explosion and the next generation of data-driven web applications with its new services offering in the cloud called Microsoft® SQL Server™ Data Services (SSDS). SQL Server Data Services (SSDS) is a highly scalable web facing data storage and query processing utility.

Built on robust SQL Server database technology, these services provide high availability and security and support standards-based web protocols and interfaces (SOAP, REST) for rapid provisioning and ease of programming.

Businesses can store and access all types of data from birth to archival, using Microsoft SQL Server Data Services. Users can access information on any device, from the desktop to a mobile device.

Read on to learn how SQL Server Data Services deliver on the Microsoft Data Platform vision and meets the needs of the next generation of data-driven applications.

http://www.microsoft.com/sql/dataservices/default.mspx

VBScript Active Directory LDAP ANR Query

Here’s a really simple Active Directory ANR (Ambiguous Name Resolution) query that uses VBScript and ADO. 


name = "ian"

Set objDomain = GetObject ("LDAP://rootDSE")
Set conn = CreateObject("ADODB.Connection")
conn.provider ="ADsDSOObject"
conn.open "Active Directory Provider"
Set Comm = CreateObject("ADODB.Command")
Set Comm.ActiveConnection = conn
Comm.CommandText = "<LDAP://" & objDomain.get("defaultnamingcontext") & ">;(&(objectCategory=User)(anr=" + name + "));displayName,AdsPath;subtree"

Set rs = Comm.Execute
Set objUser = GetObject(rs.Fields("ADsPath").Value)

msgbox objUser.Get("mail")

Lotus Notes DXL to remove Design Element Inherit from the design template

There is no easy way in Domino Designer Client to clear the “Inherit from the design template” design element property from all design elements.  The best you can do is to view all the forms, highlight those that show as inheriting from a design template as clear the property.  But you have repeat this for Forms, Views, Agents, Script Libraries, etc.

When copying and pasting design elements from one database to another, if the source database is defined as a template then the following dialog box will appear:

If you answer yes to this prompt then the design element will be set to inherit from the source database.

To clear the property from all design elements use the following Agent code, which uses DXL to export, update and overwrite the design element.


Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim note As NotesDocument
Dim noteCollection As NotesNoteCollection
Dim stream As NotesStream
Dim domParser As NotesDOMParser
Dim exporter As NotesDXLExporter
Dim importer As NotesDXLImporter
Dim attrib As NotesDOMAttributeNode
Dim nid As String
Dim found As Boolean
Dim i As Integer

Set db = session.CurrentDatabase

'Get a note collection of all the design elements
Set noteCollection = db.CreateNoteCollection(False)
noteCollection.SelectAllFormatElements False
noteCollection.SelectAllDesignElements True
noteCollection.BuildCollection

'Loop through the note collection
nid = noteCollection.GetFirstNoteId
For i = 1 To noteCollection.Count
Set note = db.GetDocumentByID(nid)

'Create a stream to store the DXL export output
Set stream = session.CreateStream
Set exporter = session.CreateDXLExporter
'Create a DOMParser to manage the DXL
Set domParser = session.CreateDOMParser(exporter, stream)
'Export the design element to the DOMParser
exporter.SetInput note
exporter.SetOutput domParser
exporter.Process

'Get the fromtemplate attribute from the exported XML
Set attrib = domParser.Document.DocumentElement.GetAttributeNode("fromtemplate")

'If the fromtemplate attribute exists and is not blank we need to blank it and import the DXL
If attrib.isNull = False Then
If attrib.AttributeValue <> "" Then
attrib.AttributeValue = ""
'Serialize the DXL so the importer has data to work with
domParser.Serialize
Set importer = session.CreateDXLimporter(stream, db)
importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE
importer.Import
End If
End If

nid = noteCollection.GetNextNoteId(nid)
Next

End Sub