Showing posts with label Workflow. Show all posts
Showing posts with label Workflow. Show all posts

Tuesday, July 26, 2011

Failed to associate this workflow template with a Microsoft Office SharePoint list

Scenario:
I have been building and deploying my Sharepoint Sequential Workflow with no issues.

Now I started to get following error: output details are as below

Successfully installed this assembly into the global assembly cache: CustomWF.dll.
Successfully restarted Internet Information Services (IIS).
Successfully copied workflow.xml to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\CustomWF\workflow.xml.
Successfully copied feature.xml to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\CustomWF\feature.xml.
Successfully installed the workflow template to Microsoft Office SharePoint Server.
Failed to associate this workflow template with a Microsoft Office SharePoint list. Object reference not set to an instance of an object.
Failed to deploy the workflow template to Microsoft Office SharePoint Server.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========


Solution:
While I was not to totally find the real cause of the issue but did a workaround to move forward.

Steps:
1. Created folder structure 12\TEMPLATE\FEATURES\CustomWF
2. Moved the feature.xml inside the folder
3. Moved the element.xml inside the folder
4. Build WSP using WSPBuilder

Article:
Open issue

Thursday, April 28, 2011

SharePoint Designer Workflow publish error

Scenario:
I was working on a small POC Workflow but as there were new ideas I keep adding more steps to my workflow.

Workflow was saving fine and was not getting any error when I do error validation
but All of sudden started getting below error when Publishing my WF.

Error were found when compiling the workflow. The workflow files were saved but cannot be run.

Advanced: Unexpected error on server associating the workflow


wferror

Possible Reason(s):
As I was not getting any error while error validation using SPD, I realized its something to do with SPD --> Web Application communication.

Another thing I noticed that I was able to publish small Workflow but I was getting error on only big once. So I guess it was request size / timeout related issue.

Solution:
Increase the web application execution time

Steps:
1. Navigate to web.config file of the WebApplication
Usually its @ C:\inetpub\wwwroot\wss\VirtualDirectories\xxxx\web.config

2. Look for this

<httpRuntime maxRequestLength="51200" />
3. Replace with
<httpRuntime maxRequestLength="51200" executionTimeout="300" />
That's all

Thursday, July 29, 2010

Error copying reusable workflow

Scenario:
SharePoint has reusable workflows newly introduced in SP2010. Using SPD you can also modify existing workflows to fit your requirements.

Today I asked my collegue to work on a task which required to reuse an OOTB workflow. But when she click on 'Copy & Modify' button from the ribbon. She keep getting following errors:

This workflow is readonly. Would you like to make a copy of this workflow to open or edit ?
error1

On saying Yes , you get 'Server could not complete your request.For more specific information, click the Details button.'
error2

Solution:
SharePoint will continue to be popular for its weird error message. As in this case.. no error message :)

One of the reason this can happen is if you are working on a sub-site of site collection.

Switch to RootWeb of the site collection and using SharePoint Designer try copying the Workflow, it will work.

Monday, July 19, 2010

Workflow Visualization Visio not showing

Scenario:
In SP2010 we have option to Visualize a workflow. But I created a new instance of OOTB approval workflow and it was missing the Visualization.. so whats going on ??

Check few things:

Ensure that you have Visualization option turned on for your workflow.Here's what you need to look for in SPD.
option

Check for the feature to enable visio web access
feature

Also make sure Visio Graphic Service is started.
visiossa

Article:

Sunday, January 25, 2009

Workflow Auto cleanup days fix

Scenario:
This is not new, most of us who have written atlease one Workflow in sharepoint knows this. Workflow History List is a the place where we log the progress/ comments during the Workflow progress and because of performance issues reason this list is cleaned every 60 days. But your client may not be very happy about this as they usually want to retain the history for X,Y,Z reasons.

Solution:
Fortunately SPWorkflowAssociation class exposes AutoCleanupDays property and the clean up job checks the values ( in days ) before deleting the entry from the Workflow List.

Here's a small utility which can help you fix the values of AutoCleanupDays.

Code:

Code Snippet
/*
* Date: September 17, 2007
** Program Description:
* ====================
* This program is a workaround for Microsoft Office SharePoint Server 2007
* bug #19849, where the AutoCleanupDays is set to 60 by default and by design
* in MOSS installations. This program gives the customer the oppotunity to
* change this number.
* Workflow histories would not show after 60 days by default.
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;

namespace ProjectName{

class Program{

static string siteName;
static int newCleanupDays, assoCounter;
static string libraryName, wfAssoName;
static SPSite wfSite;
static SPWeb wfWeb;
static SPList wfList;

static void Main(string[] args){

try{

switch (args.Length){

case 0:{ //no parameters entered by user
System.Console.WriteLine("Error: No arguments entered (site, library, workflow and days)");
showHelpUsage();
break;
}

case 4:{ //correct number of parameters
siteName = args[0];
libraryName = args[1];
wfAssoName = args[2];
newCleanupDays = Convert.ToInt32(args[3]);
assoCounter = 0;
wfSite = new SPSite(siteName);
wfWeb = wfSite.OpenWeb();
wfList = wfWeb.Lists[libraryName];
SPWorkflowAssociation _wfAssociation = null;

foreach (SPWorkflowAssociation a in wfList.WorkflowAssociations){

if (a.Name == wfAssoName){
a.AutoCleanupDays = newCleanupDays;
_wfAssociation = a;
assoCounter++;
}
else{
_wfAssociation = a;
}
}

wfList.UpdateWorkflowAssociation(_wfAssociation);

System.Console.WriteLine("\n" + wfAssoName + ": " + assoCounter.ToString() + " workflow association(s) changed successfuly!\n");
break;
}

default: {//default number of parameters

System.Console.WriteLine("Incorrect number of arguments entered (" + args.Length.ToString() + " arguments)");
showHelpUsage();
break;
}
}
}
catch (Exception e){
System.Console.WriteLine("An error has occurred. Details:\n" + e.ToString());
}
finally {
if (wfSite != null)
wfSite.Dispose();

if (wfWeb != null)
wfWeb.Dispose();

System.Console.WriteLine("\nFinished setting AutoCleanupDays!");
}
}

static void showHelpUsage() //help screen
{
System.Console.WriteLine("\n\nMOSS Workflow Set AutoCleanup Usage:");
System.Console.WriteLine("====================================");
System.Console.WriteLine("ShowWFs siteURL library workflow days");
System.Console.WriteLine(" - siteURL (e.g. http://serverURL/site)");
System.Console.WriteLine(" - library (e.g. \"Shared Documents\")");
System.Console.WriteLine(" - workflow (e.g. \"Approval\")");
System.Console.WriteLine(" - days for auto clean up (e.g. 120)");

}
}
}
Article:
Thanks to Shola Shaloko for the Code

MSDN

Monday, January 19, 2009

The type or namespace name 'Office' does not exist in the namespace 'Microsoft'

Scenario:
I was on a WSS machine ( not MOSS ) and was trying to demonstrate a basic workflow. But when I tried building the project. I got this:

Error: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Solution:
This was simple for me but might be confusing for someone who is new to workflow and doesn't understand difference between WSS vs MOSS.

Microsoft.Office , infact anything in the namespace is specific to MOSS only and is not available in WSS installation. That doesn't mean you cant write a workflow, but certainly we cant use the MOSS specific features in this workflow.

So to proceed further , follow these steps :

1. Go to project references
--> Remove Microsoft.Office.Workflow.Tasks binary reference

2. Go to Workflow class ( i.e. Workflow1.cs )
--> Remove using Microsoft.Office.Workflow.Utility;

3. Go to feature.xml file
-->Remove these lines
ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"

Saturday, January 17, 2009

Administrator may need to add a new request Url mapping to the intended application

Scenario:
I was trying Visual Studio Extension for Workflow and go the following error while creating a new workflow. I added a new project , it poped-up a screen asking for the Url to the site , I want to attach the workflow... now the thing is it already had a default value 'http://spvm/docs' and if i go ahead with the default value, it gave me error saying -- Check for the Url to the site , Administrator may need to add a new request Url mapping to the intended application

Solution:
Basically its very simple , wizard expect Url to the site and not the document library or list you want to attach workflow. So I changed the Url from

http://spvm/docs >> http://spvm

and it worked.

Thursday, January 8, 2009

Workflow clean-up job

Scenario:
SharePoint workflow activities include LogToWorkflowHistory and basically it logs an entry into the Workflow History List you selected while associating the workflow with List or Item.

Also another thing is that usually we write entries to this History List quite often to see the workflow progress which means multiple entries per Workflow execution. As with any SharePoint list, if your workflow history list exceeds 2000 items, site performance may be impacted. So sharepoint out of box has a Workflow clean-up job , which runs every day and delete the items older than 60 days.

Workflow history is not intended to be used as a means of auditing workflow events and is not necessarily secure.There are other better way to do it. Read about auditing.

Solution:
1. You can create a separate history list for each workflow association. But still you need to find out a way for history getting deleted which is 60 days old.
2. You can disable automatic cleanup of workflow history. ( This is the only fix to avoid deletion of the history information , but then you need to plan how to keep the list within 2000 item limit to avoid performance issues )

:-)

Saturday, September 6, 2008

Provisioning Workflow programatically

Scenario:
You want to provision a Workflow programatically for a given list/document library

Steps:
01. Create an SPList object that references a list or document library that hosts the items used by the workflow.
02. Create an SPList object that references an approval task list.
03. Create an SPList object that references the Workflow History list.
04. Create an SPWorkflowTemplate object by using the workflow GUID from Workflow.xml.
05. Create an SPWorkflowAssociation object that connects the SPWorkflowTemplate object with the SPList objects for the approval task list and the Workflow History list.
06. Add an SPWorkflowAssociation object to the SPList object you created in the first step.

Code:

public void ProvisionWorkflow(SPWeb web)
{
using (web)
{
//Bind to lists.
SPList approvalsList = web.Lists["Your Approval List Name Goes Here"];
SPList approvalTasksList = web.Lists["Task List"];
SPList workflowHistoryList = web.Lists["Workflow History"];

//WorkflowGUID is the workflow GUID
//from workflow.xml\<Elements>\<Workflow>\[ID].
SPWorkflowTemplate workflowTemplate =
web.WorkflowTemplates[new Guid("WorkflowGUIDWithoutBraces")];

//Create workflow association.
SPWorkflowAssociation workflowAssociation =
SPWorkflowAssociation.CreateListAssociation(workflowTemplate,
workflowTemplate.Description, approvalTasksList,
workflowHistoryList);

//Set workflow options.
workflowAssociation.AllowManual = true;
workflowAssociation.AutoStartChange = true;
workflowAssociation.AutoStartCreate = false;

//Add workflow association.
SPWorkflowAssociation workflowAssociationInList =
approvalsList.AddWorkflowAssociation(workflowAssociation);
}
return;
}

Friday, September 5, 2008

SharePoint Workflow using Visual Studio 2005 with Extensions

Scenario:
You need to write a basic workflow in sharepoint. Once you associate the workflow to a document library , if you upload a document into the library and start the workflow, it will make an entry into TASKS list and another entry into WorkflowTASKS list.

Assumption:
You have Visual Studio 2005 and Extensions for SharePoint installed.

Solution:
01. Open Visual Studio 2005
02. Create new C# Project of type 'Sequential Workflow Library' from SharePoint node
03. Name it 'TestWorkflow'
04. Visual Studio Extension will create some files for you required for deployment.
05. Open 'Feature.xml' and modify it as given in sample below.
06. Open 'Workflow.xml' and modify it as given in sample below.
07. Now open the 'Workflow1.cs'

08. Add a 'CreateTask' activity below 'OnWorkflowActivated'
09. Add a 'LogToHistoryTaskActivity' activity below 'CreateTask'
10. Open 'CreateTask' properties window
11. Click on browse button for taskID > Bind to a new Member > Create Field > Name it 'taskId' > OK
12. Click on browse button for taskProperties > Bind to a new Member > Create Field > Name it 'taskProperties' > OK
13. Double Click on 'CreateTask' and following lines of code

taskId = GUID.NewGUID();
taskProperties.Title = "Task created by workflow" ;
14. Click on 'LogToHistoryTaskActivity' activity and set the
History Description to 'Task Created'
15. Add 'OnTaskChanged' activity
16. Set correlationToken to 'taskToken' and TaskID to 'taskId' , TaskProperties to 'taskProperties'
16. Add a 'CodeActivity'
17. Double click and enter the following code
SPList item = workflowProperties.Item;
SPList task = workflowProperties.TaskList.GetItemById(taskProperties.TaskId);
item.Title ="Task updated by workflow";
item.SystemUpdate(false);

18. Add a 'DeleteTask' activity and set its correlationToken to 'taskToken' and TaskID to 'taskId'

19. Strong Name the project
20. Build the project
21. Run the 'Install.bat'
22. Now this workflow will be available on your local machine for use.

Feature.xml:
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="{NewGUIDWithBraces}"
Title="Test Workflow"
Version="1.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/" >
<ElementManifests>
<ElementManifest Location="workflow.xml"/>
</ElementManifests>
<Properties>
<Property Key="GloballyAvailable" Value="true" />
</Properties>
</Feature>
Workflow.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Workflow Name="My workflow"
Id="NewGUIDWithOUTBraces"
CodeBesideClass="TestWorkflow.Workflow1"
CodeBesideAssembly="TestWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ReplaceITWithKey"
>
</Workflow>
</Elements>
Article:
http://msdn.microsoft.com/en-us/library/ms580283.aspx
http://blogs.msdn.com/nikhil/archive/2008/01/19/sharepoint-workflow-feature-in-vs-2008-part-ii.aspx#8584351