Pages

Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Wednesday, November 21, 2012

Sequential Work Flow in SP 2010 Using VS 2010


Introduction
In this article we will see how to create a sequential work flow in SharePoint 2010 using VS 2010.

Objective
Let's make the scenario simple. We want to create a simple work flow and if the work flow status is not completed, we need to prevent the user from deleting the document.

Steps
First we need to create a "Status" column with a Choice field type with various status options in our Document library.
Sequenceworkflow1.jpg
Once the "Status" column  was created, the document library will be as shown below:
Sequenceworkflow2.jpg

Open the VS2010 -> Select SharePoint 2010 -> Select the Sequential work flow project type and complete the wizard as shown below.
Sequenceworkflow4.jpgSequenceworkflow4.jpgJust click the OnWorkFlowActivated step and create an event called OnWorkFlowActivated_Invoked:Just click the OnWorkFlowActivated step and create an event called OnWorkFlowActivated_Invoked: Just double-click the onWorkflowActivated step. It will redirect to the code behind file.Drag a while loop step from the Tool Box, below the onWorkflowActivated step:Drag a while loop step from the Tool Box, below the onWorkflowActivated step: 
Sequenceworkflow9.jpg Sequenceworkflow11.jpg



Invoke the "IsWorkFlowPending" method in both the "onWorkflowActivated_Invoked" and the "onWorkflowItemChanged1_Invoked" methods.Invoke the "IsWorkFlowPending" method in both the "onWorkflowActivated_Invoked" and the "onWorkflowItemChanged1_Invoked" methods.Let's deploy the solution and we will check whether or not the workflow is deployed in our document library.Let's deploy the solution and we will check whether or not the workflow is deployed in our document library. 

Upload a document and start the workflow: We will see the workflow status as "InProgress" in the document library. Edit the task and change the status to Approved. Our workflow status will change to "Completed". We can prevent the user from "Deleting" the document, if the "Status" is not completed. Just add an Event Receiver in the same work flow project. 







Sequenceworkflow23.jpgLet's check the code in the UI using a document which is in the InProgress Status and try to delete the document.Let's check the code in the UI using a document which is in the InProgress Status and try to delete the document. If we click ok also the document is still in our repository. Let's make some changes in the code to display a user friendly message: Now when we try to delete the document we will see the following message. Summary                We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.                We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.
                
We created a simple work flow in VS 2010 and prevent the users from deleting a document, if its not approved.







Sequenceworkflow3.jpg
By default we have the following simple start page:
Sequenceworkflow5.jpg
Sequenceworkflow6.jpg
Sequenceworkflow7.jpg
Sequenceworkflow8.jpg
Select the while loop step and in the property window configure the "Condition" as "Code Condition" and create an event called "IsWorkFlowPending".
Sequenceworkflow10.jpg
Sequenceworkflow12.jpg
Sequenceworkflow13.jpg
Sequenceworkflow14.jpg
Sequenceworkflow15.jpg
Place the following in the our workflow:
Sequenceworkflow16.jpg
Sequenceworkflow17.jpg
Sequenceworkflow18.jpg
Sequenceworkflow19.jpg
Sequenceworkflow20.jpg
Sequenceworkflow21.jpg
Sequenceworkflow22.jpg
In the code behind file, we will prevent the user from deleting a document if the status is "Pending".
Sequenceworkflow24.jpg
Sequenceworkflow25.jpg
Sequenceworkflow26.jpg
Sequenceworkflow27.jpg
Sequenceworkflow28.jpg


Summary



Monday, November 5, 2012

Windows Store App (Metro UI) Design in SharePoint 2010


Objective

We want to implement the Windows Store App (Metro UI) themes in our SharePoint 2010 pages.

Steps

We are not going develop the CSS and pages from scratch. We will try to implement the code project solution file for CSS and design.

Site Link

http://www.lifeinsharepoint.co.uk/2011/12/03/metro-ui-sharepoint-2010-masterpage-solution/

CodePlex Link

http://lifeinsharepoint.codeplex.com/releases/view/78033

First download the WSP file and install it in the SharePoint Server. We can use the PowerShell command to simplify the process.

Add Solution

Add-SPSolution c:\solutionpath\LifeInSharePoint.Metro.wsp

Deploy Solution

Install-SPSolution -Identity LifeInSharePoint.Metro.wsp -WebApplication http://myprojectsite -GACDeployment

Once it's successfully deployed, we can check the deployment files in 14 hive path as mentioned in the following path.
Install-SPSolution –Identity-LifeInSharePoint.Metro.jpg

Go To -> Site Collection Administration -> Site collection Features; we can see the installed feature with the name "SITE.LifeInSharePoint.Metro"

SITE.LifeInSharePoint.Metro.jpg

Before we activate the feature, we will see the following design for sites and pages.

activate-the-feature-Windows-Store-App.jpg

Site Collection Admin page looks like the following page:

Site-Collection-Admin-page.jpg

Activate the feature, make sure site collection's publishing feature is already activated in the site collection.

SITE.LifeInSharePoint.Metro1.jpg

As soon as the feature has activated, we will immediately make the design (UI) changes.

Site-Collection-Administrator.jpg

The entire site's design has changed to that of a Windows Store App (Metro UI):

sites-design-changed-to-Windows-Store-App.jpg

Summary

Creating a SharePoint site in Windows Store App (Metro UI) is fun. Still we are using the CodePlex tool; we will understand the basic design principles behind the scene.

UI Design Principle

http://msdn.microsoft.com/en-us/library/windows/apps/hh464920.aspx 

Hide Top Level Menu and Ribbon Programmatically in SharePoint 2010


Introduction
In this article we will see how to hide a top level menu and ribbon programmatically in SharePoint 2010.
Steps: Let's assume that we have a site page with top-level navigation menus and Ribbon Controls.
Go to a site pages and add new page.
Add-New-Page-in-SharePoint.jpg
Once the page is created, if we click the page we are able to see the page with the top-level navigation menu with ribbon controls.
Top-level-navigation-menu-with-ribbon-control-in-SharePoint.jpg
Before we edit the site page, we need to save the following code in Shared Documents.
Code
<style type="text/css">
  #s4-leftpanel-content{        display:none;}   #s4-ribbonrow
{        display:none;}   #s4-titlerow{        display:none;}   #s4-workspace  {         overflow-yhidden !important;  }</style> 
We need to save this code in the shared documents as a text file as shown in the following:
document-as-text- file-in-SharePoint.jpg
Now we can start the edit pages.
Go to à Site Actions à Edit Page.
Edit-page-in-SharePoint.jpg
Edit-page-in-SharePoint(Image4)
Once we are in Edit Page Mode, just select the two columns layout this demo.
Text-Layout-option-in-sharePoint.jpg
Just click the second column and add a content editor web part:
contend-editor-in-SharePoint.jpg
editing-tool-in-SharePoint(Image7).jpg
Once it's added, click the Edit web part and select the above share document in the content link.
editing-tool-in-SharePoint.jpg
Content-editor-in-SharePoint.jpg
That's all our page will load with the following UI Changes:

page-in-SharePoint.jpg
We will see the content editor in our page that's not required to view in page content. We will again edit the content editor web part and set the "Chrome Type" to "None".
Content-editor-Option-in-SharePoint.jpg
Finally the page looks like the following image:
page-looks-in-Sharepoint.jpg
The preceding steps need to be followed for site pages, but if added for a web part page, we will see how easy it is to hide the Ribbon and navigation controls.
Site-page-in-SharePoint.jpg
Just create a web part page template, select the options which we want and create the page.
page-template-in-SharePoint.jpg
In the web part page, we have various options to inject our HTML code.  We can add "HTML Form Web Part" or using the "Content Editor Web part". We will see both options.
Select content "HTML Form Web Part". In the Edit web part mode just copy the above code in the Source Editor and save it.
HTML-Form-Web-Part-in-Sharepoint.jpg
HTML1-Form-Web-Part-in-Sharepoint.jpg
We will set the chrome type to "None" to hide in the UI.
Select-Hide-from-crome-type-in-sharepoint.jpg
We will see the output as shown in the following image, just added the default announcements list for demo.
announcements-in-sharepoint.jpg
Let's see how we can get the same result using the "Content Editor" web part. Go to the web part page edit mode, delete HTML form editor and add the using "Content Editor" web part.
delete-HTML-Form-editor-in-sharepoint.jpg

delete1-HTML-Form-editor-in-sharepoint.jpg
In the web part page, just click the "Click here to add new content" link and select HTML and Edit HTML Source option from the ribbon.

Edit HTML Source-In-sharepoint.jpg
Now we can add our code, save the changes and refresh the page and we will get the final output.

output-In-sharepoint.jpg
Summary
We have seen various options to hide a top level menu and ribbon programmatically in SharePoint 2010. If we add the same code in a Master Page using the SharePoint 2010 Designer, we will hide controls in the entire pages.