Adding OOTB workflow to document library using CSOM

Hi,

     I have the requirement to add OOTB(out of box) workflows to a document library using CSOM(Client side object model).

I have gone through many links, I have come across this link 

http://code.msdn.microsoft.com/office/Start-a-workflow-instance-ab5ffecb#content

but that is not working for me.

Any kind of Help will be helpful

Thanks & Regards

MSabir

April 23rd, 2014 9:52am

Hi,

The link you provided relates to how to start a workflow instance.

According to your description, you might want to find code about adding workflow to a specific list.

The documentation below from MSDN will show how to retrieved all the installed workflow definitions and create a workflow association to a specific list(add a workflow to a list) with code demos:

http://msdn.microsoft.com/en-us/library/office/dn481315(v=office.15).aspx

 

Best regards
Free Windows Admin Tool Kit Click here and download it now
April 24th, 2014 5:44am

Hi,

If you work with console application, you will need to add reference to the three dlls first:

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.WorkflowServices.dll

Best regards

April 24th, 2014 7:20am

Hi Patrik,

Thanks for you reply but I am not able to load workflow service manager

it gives following error:

Value cannot be null.

Parameter name: uriString

And also I don't know how to give reference for this following js files in a console application

sp.js,

sp.runtime.js and

sp.workflowservices.js

Regards

MSabir

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2014 8:36am

But I am not able to initialize workflow service manager object it gives following error
Value cannot be null.

Parameter name: uriString
 My code sample:
  WorkflowServicesManager workflowServicesManager = new WorkflowServicesManager(clientContext, web);
            clientContext.Load(workflowServicesManager);
            clientContext.ExecuteQuery();
error is thrown at "clientContext.ExecuteQuery();" 
April 24th, 2014 9:13am

Hi,

Before executing the query, please apply credential to the ClientContext object as the link shows below:

http://www.vrdmn.com/2013/01/authenticating-net-client-object-model.html

You can run the code provided in the link, if it runs successfully, then you can reference the dlls needed and access the WorkflowServicesManager object.

Best regards

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2014 9:34pm

Hi,

Still it is giving same error.

April 25th, 2014 1:21am

Hi,

Can you run the demo successfully which provided in that link?

After you have executed the sample code with Client Object Model successfully, then you can try to access the WorkflowServicesManager object.

Best regards 

Free Windows Admin Tool Kit Click here and download it now
April 25th, 2014 3:40am

Hi, 

Actually i am not using SharePoint online I am using SharePoint 2013 onPremise and for that I am providing credential as below:

 ClientContext clientContext = new ClientContext("my site url");
            System.Net.NetworkCredential cred = new System.Net.NetworkCredential("login name", "password", "domain name");
            clientContext.Credentials = cred;

after that I tried getting workflow service manager object but it returned same error.

Regards

MS

April 25th, 2014 5:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics