Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Tuesday, June 26, 2012

SharePoint Interview Questions and Answers: Workflows


SharePoint Foundation 2010 workflows are made available to end-users at the list or document-library level. Workflows can be added to documents or list items. Workflow can also be added to content types.
Multiple workflows may be available for a given item. Multiple workflows can run simultaneously on the same item, but only one instance of a specific workflow can run on a specific item at any given time.
For example, you might have two workflows, called “SpecReview” and “LegalReview”, available for a specific content type, Specification. Although both workflows can run simultaneously on a specific item of the Specification content type, you cannot have two instances of the “LegalReview” workflow running on the same item at the same time.
Workflow forms:


Three types of forms are used in SharePoint Foundation workflows:
Association and Initialization Forms: Association and initialization forms are displayed for users to fill out before any workflow is actually started. You can use these forms to enable users to set parameters and other information for the workflow before it starts.

Modification Forms:   Modifications are options you present to users to change the workflow as it's running on an item. You can then create modification forms that enable users to specify the parameters of the modification.

Task Forms:  You can also specify custom forms for the tasks in your workflow. Because tasks are SharePoint items that are assigned a content type, however, the content type actually determines the custom forms used with the task type.

Workflow life cycle:
SharePoint workflow cycle is very much unique to SharePoint environment. SharePoint workflows are always connected in context with SharePoint content like list or a document.
There are four stages in the SharePoint workflow cycle. They are 

Associate: Association forms address how the workflow applies to a specific list, library, or content type. In this stage, workflow is associated with a content type like list or a document.
Association forms are displayed to administrators when they first decide to add—or associate—a workflow with a particular list, document library, or content type.

Initiate: Initiation forms address how the workflow applies to a specific SharePoint item. In this stage, the workflow created is to be initiated. Workflow are noting but classes. So a workflow instance needs to be created to start the workflow in action.
Initiation forms are displayed to users when they start a workflow on a specific SharePoint item.

Modify: In third stage, the instance of the workflow is modified as per the workflow stages.

Complete: Finally the workflow object is terminated.
Workflows and types of workflows?
SharePoint 2010 workflows are based on Windows Workflow Foundation (WF). WF is part of .NET 3.5 Framework.

Sequential workflows?
  1. In sequential workflows, the activities are placed in a logical order with an explicit start and an explicit end.
  2. The activities are executed sequentially one after the other like a flow chart.
  3. There is no going back to the previous step in a sequential workflow. 
Workflow object model:
  • Associate workflows to the list, library and content type:
  • To associate a workflow to a list or document library, use the AddWorkflowAssociation method of the SPList object.
  • To associate a workflow with a content type, use the AddWorkflowAssociation method of the SPContentType object.
  • Both of these methods take an SPWorkflowAssociation object and add it to the specified list or content type, respectively.
  • Remove workflow association from the list, library and content type:
  • Use the RemoveWorkflowAssociation method to remove a workflow association from a list, and the RemoveWorkflowAssociation method to remove a workflow association from a site or list content type.
Managing workflows instances programmatically:
Use the SPWorkflowManager object to manage the running instances of workflows across a site collection. The SPWorkflowManager object has no equivalent in the user interface. Use the SPWorkflowManager object to:
Start, run, or cancel workflows.
Return all the workflows currently running on a specific item.
Perform other workflow administration operations.
To manually start a specific workflow for an item—that is, a workflow that is not configured to start automatically—use the StartWorkflow(SPListItem, SPWorkflowAssociation, String) or StartWorkflow(SPListItem, SPWorkflowAssociation, String, Boolean) method.

Difference between event receivers and workflows?
Unlike Workflows, Event Receivers cannot be triggered manually.
Event receivers will support both Before/After properties but workflows supports only after properties [Means u can’t able to perform “ing” operations].
SharePoint event handlers run for a short period of time (generally seconds), while SharePoint workflows may run for a much longer time period (days, months, or even years).
 
Difference between SharePoint designer workflows and custom workflows?
  1. Only sequential workflows can be created in SharePoint Designer; state machine workflows cannot be created in SharePoint Designer.
  2. Deployment and moving is easy in custom workflows when compared to SharePoint designer workflows.
  3. Visual Studio can have code-behind.
  4. Visual Studio generates a workflow template which can be easily be deployed, SharePoint Designer workflows are typically built against specific lists and sites.
  5. Visual Studio allows for debugging!!
Why custom workflows can’t be deploying using sandbox solution?
In Workflow activity we have an .ACTIONS file. The .ACTIONS file will be stored in Physical Directory. But in Sandbox, we can't move any file to Physical location.
Name
Available for sandboxed solutions
Sequential Workflow
No. Programmatic workflows are not available for sandboxed solutions.
State Machine Workflow
No. Programmatic workflows are not available for sandboxed solutions.
Import Reusable Workflow
No. Programmatic workflows are not available for sandboxed solutions.
Import SharePoint Solution Package
Yes, if the items that is imported from the package are supported.
Workflow Association Form
No. Association forms include .aspx files and are not available for sandboxed solutions.
Workflow Initiation Form
No. Initiation forms include .aspx files and are not available for sandboxed solutions.

What type of issues you faced while developing workflows?
This view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold enforced by the administrator.
 
We will not get the metadata of document library when you assigned workflow. Workflow will immediately trigger once you upload doc to the doc library. So that’s the reason you can’t get the metadata of document library. So, I called my custom workflow manually in ItemAdded event.

How to attach workflows to the content types?
 
//To attach it for specific content type
<AssociationCategories>
ContentType;0x010100a945f312c7bd4a589d1489ca8307f24d</AssociationCategories>
//To attach it for all content types
<AssociationCategories>ContentType</AssociationCategories>
//To attach it for specific content type
<MetaData>
<AssociationCategories>
ContentType;0x010100a945f312c7bd4a589d1489ca8307f24d
;#ContentType;0x0101009a30bd7a9c18447e9b806af9c0931b9c
</AssociationCategories>
</MetaData>

How to attach workflows to the list and library?
  <Workflow
     Name="WorkflowProject1 - Workflow1"
     Description="My SharePoint Workflow"
     Id="d011cd8b-a95d-4d3e-bd53-e88345bbf5c4"
     CodeBesideClass="WorkflowProject1.Workflow1.Workflow1"
     CodeBesideAssembly="$assemblyname$">
    <Categories/>
    <MetaData>
      <AssociationCategories>List</AssociationCategories>
      <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
    </MetaData>
  </Workflow>
</Elements>

Remember points:
Workflows run with “system account” by default.
InfoPath forms cannot be created with Visual Studio. Previous versions of Visual Studio provided that capability but it was removed from the current 2010 version.

Other debugging tips:
Failed on Start usually means an error is happening in SharePoint before your workflow code spins up, such as not being able to find the workflow dll.  Error Occurred usually means the workflow started and the error is somewhere in the code.

Check the SharePoint ULS logs! – Fatal workflow errors might happen outside of your workflow, so they aren’t always visible in the debugger.  Consult the logs to see if this is the case by opening the latest log and searching from the bottom up for “Workflow”.  The logs are awesome resources that often get overlooked.  Logs can be found in %Program Files%\Common Files\Microsoft Shared\web server extensions\12\LOGS.
This view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold enforced by the administrator.
Coded workflows cannot be deployed in a sandboxed solution.
Only a Reusable workflow—not a List workflow or a Site workflow—can be saved as a sandboxed solution in SharePoint Designer.
A workflow that is published as a Global Reusable workflow cannot be directly saved as a sandboxed solution in SharePoint Designer. However, you can copy it as a non-global workflow, which you can then save as a sandboxed solution. [ http://msdn.microsoft.com/en-us/library/gg615452.aspx ]



4 comments:

  1. Very nice post! Thanks!

    ReplyDelete
  2. Thanks Sasikumarreddy garu,It is helpful to me From Chandramohanreddy.Please send ur mail id to me:chandutosss@gmail.com...please....please....please........

    ReplyDelete
  3. the posts are very helpful 10 on 10... but please remove that twitter plugin..it gets all over the page distracting all the time

    ReplyDelete
  4. Thanks Akshay for visiting my blog and given nice feedback.

    ReplyDelete