Friday, February 17, 2012

Issues after deploying SharePoint 2010 Designer Reusable Workflow

Hi,

I got the below issue from one of our colleague in our practise.

Issue
We need to deploy SharePoint designer reusable workflow for approval process to other site collections. We try to get the WSP file from SharePoint Designer using ‘Save as Template’. We try to Import Reusable workflow to Visual Studio using WSP generated above. We try deploy it to other sites and then we are facing the following issues.
1. When we try to Add a workflow to a list, the deployed workflow is listed in All content types. And when we try to select the custom content type we generated, the workflow is not displayed.
2. After adding that workflow to that list, when we initiate that workflow to a list item, it is creating a task. But when we try to edit that task form it is giving page not found error.

Considering this scenario, it would help us if anyone can provide us the deployment approach for a re-usable SharePoint Designer 2010 workflow as a WSP solution package.

After understanding the above,one of my teammate gave the solution as below i.e creating the feature and attaching to workflow association.


Reply
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{

SPWorkflowTemplate workflowTemplate = null; // Workflow template
SPWorkflowAssociation workflowAssociation = null; //Workflow association
SPList historyList = null; // Workflow history list
SPList taskList = null; // Workflow tasks list
SPList list = null;
//Sharepoint List
using (SPSite site = (SPSite)properties.Feature.Parent)
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
workflowTemplate = web.WorkflowTemplates.GetTemplateByName(SPPROCWorkflowAssociationConstants.WorkFlowName, System.Globalization.CultureInfo.CurrentCulture);
list = web.Lists[SPPROCWorkflowAssociationConstants.TargetLibrary];
historyList = web.Lists[SPPROCWorkflowAssociationConstants.HistoryList];
taskList = web.Lists[SPPROCWorkflowAssociationConstants.TaskList];
SPContentType ctType = list.ContentTypes[SPPROCWorkflowAssociationConstants.ContentType];
try
{
// Create workflow association
workflowAssociation = SPWorkflowAssociation.CreateListContentTypeAssociation(workflowTemplate, SPPROCWorkflowAssociationConstants.WorkFlowName, taskList, historyList);
// Set workflow parameters
workflowAssociation.AllowManual = true;
workflowAssociation.AutoStartCreate = false;
workflowAssociation.AutoStartChange = false;
// Add workflow association to my list
ctType.WorkflowAssociations.Add(workflowAssociation);
// Enable workflow
workflowAssociation.Enabled = true;
}
catch(Exception exception)
{
SharePointLogger.Local.TraceToDeveloper(exception, exception.Message);
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
}

}

Monday, February 13, 2012

Datasheet view error

HI,
One day I received a query from our colleague as below
While adding a list item in Datasheet view the below error is popping up.
List Structure Has Changed
“Another user has changed the structure of this list. All your pending changes to this list will be discarded. To retrieve the latest copy of the list, click Refresh.”
Did anyone face this kind of issue? Please suggest
Earlier I too got some problems where I was copying data from excel sheet that has been shared by client and pasting in the data sheet view of the list.
With that knowledge I replied the solution as
This happens when another person tries to add or delete a column from the list while you are adding content in datasheet view. If you are consistently getting this error, it will help to use the ribbon to switch to "standard view" then back to "datasheet view" to allow the changes to 'sync up'. It's important to realize the possibility that not all columns in the list are visible in the datasheet view. Non-visible changes to columns in a list can still affect the view in datasheet if you have pending changes.

For reference of this issue you can have a look as from below link.
http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/6c62115a-f85e-4407-a919-ab4560cf2060/