Quantcast
Channel: Workflows – ..:: I like SharePoint ::..
Viewing all articles
Browse latest Browse all 12

SharePoint 2010 get workflow template id by using Javascript

$
0
0

Just a small post, but maybe it helps you. In my case i had a subsite as workspace. This subsite contains a site workflow. I inserted a modal dialog on the start page which opens the initial form for this workflow.

If a user creates a new subsites based on the template for this workspace, the site workflow gets a new template id, which is necessary for the link of the modal dialog. So my idea was to create a javascript function which get the template id of the site workflow dynamically and adds it to the modal dialog. Well what should i tell you – if it does not work, i would not have written this post.

I look for the site workflow by name. If you know any better solution i would like to hear from you. So here is the code is used. [sourcecode languag=”csharp”]

function getWorkflowId() {
var clientContext = new SP.ClientContext.get_current();
this.workflows = clientContext.get_web().get_workflowAssociations();
clientContext.load(this.workflows);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
};

function onQuerySucceeded(sender, args) {
var enumerator = this.workflows.getEnumerator();
while(enumerator.moveNext())
{
var workflow = enumerator.get_current();
if(workflow.get_name() == “My Site Workflowname”)
alert(workflow.get_id());
}
};

function onQueryFailed(sender, args) {
alert(“Error”);
};

[/sourcecode]

There are so many possibilites with the client object model and javascript which might be interesting.

..:: I LIKE SHAREPOINT ::..


Viewing all articles
Browse latest Browse all 12

Trending Articles