Archive for April, 2011

SharePoint Power Shell Script: Add Fields / Columns in existing View

Scenario:

We need to add fields / columns in existing view via power shell script

Resolution:

$site New-Object -TypeName “Microsoft.SharePoint.SPSite” -ArgumentList “Site URL”

$web $site.OpenWeb()

$list $web.Lists[“List Name”]

$fieldsName = “Created,Created By,Title,Content Type”

$fields $fieldNames.Split(‘,’)

$view $list.Views[“View Name”]

foreach ($fieldName in $fields)

{

$field $list.Fields[$fieldName]

$view.ViewFields.Add($field)

}

$view.Update()

Advertisements

Leave a Comment

SharePoint: SharePoint Diagnostic Studio is available

Leave a Comment

SharePoint Workflow: This workflow requires that the document is checked in. You must first check this document in and then start the workflow

Scenario:

We created two visual studio workflows, say, workflow A and workflow B. Workflow A starts when a document is added or changed and check out the document. We can’t start Workflow A manually. Workflow B can only be started manually. When we try to start workflow B on a document which is already checkout by the workflow A, following pop up appear:

This workflow requires that the document is checked in. You must first check this document in and then start the workflow

If we check in the document, workflow B works fine.

Resolution:

As per my understanding, the trick missing is that SharePoint workflow run with “System Account”. We have deployed two workflows. Workflow A and workflow B. First Workflow A run when document is uploaded or changed and check out the document. Document is checked out using current user token (user token of the user who has uploaded or changed the document). When we want to start Workflow B, it give us error that document needs to be check in as it was check out by another user and we can’t run workflow on it.

We changed the code of Workflow A and used system account to Check out the document. Now, when user try to run the workflow, it is already check out to “System Account” and have no issue in running.

Leave a Comment

SharePoint Workflow: Failed on Start (retrying)

Scenario:

We created a visual studio workflow which contains initiation form. Workflow was associated with multiple content types. Workflow works well when deployed using visual studio. When workflow deployed using WSP, it was crashed showing “Failed on Start (retrying)” or “Error Occurred” status.

Resolution:

When we add “Workflow Initiation Form” using “Add” -> “New Item”, following method is responsible for running workflow:

private
void StartListWorkflow()

{

SPWorkflowAssociation association = this.workflowList.WorkflowAssociations[new
Guid(this.associationGuid)];


this.Web.Site.WorkflowManager.StartWorkflow(workflowListItem, association, GetInitiationData());


SPUtility.Redirect(this.workflowList.DefaultViewUrl, SPRedirectFlags.UseSource, HttpContext.Current);

}

In the above method, following method looks for workflow association with the list:

SPWorkflowAssociation association = this.workflowList.WorkflowAssociations[new
Guid(this.associationGuid)];

But we have associated workflow with the content types, not with the list. This results in null value in the SPWorkflowAssociation type variable “association”. When “StartWorkflow” is called, it resulted in exception.

We changed the above line of code with following line:

SPWorkflowAssociation association = this.workflowList.ContentTypes[this.workflowListItem[“Content Type”].ToString()].WorkflowAssociations[new
Guid(this.associationGuid)];

In the above code, instead of finding association from list, workflow looks association using content type as workflow is associated with content type not list. This did the trick.


Comments (4)

SharePoint 2010: Forms Based Authentication Pack

Visigo Software Consulting Inc. has released forms based authentication pack for SharePoint 2010. It includes web parts for registering users, changing passwords and password recovery. It includes tools for managing users and roles and for approving registrations.

For details:

http://sharepoint2010fba.codeplex.com/

Leave a Comment

SharePoint 2010 event @ Virtual University

I spoke at an event organized by Microsoft Pakistan and Virtual University of Pakistan. The event held on Friday, April 15, 2011. I presented on SharePoint 2010 for students with CS and management background. The snaps of the event are available @ https://picasaweb.google.com/farhan.faiz/SharePoint2010EventVU#.

Thanks to Ali, people at VU and people at Microsoft Pakistan for the event.

Leave a Comment

SharePoint Live Chat with MVPs: Wednesday, April 20th.

Microsoft schedule a chat session with the MVP Experts for SharePoint on: Wednesday April 20th at 9am PDT

For more information:

http://msdn.microsoft.com/en-us/events/aa497438.aspx

Leave a Comment

Older Posts »