Monday, April 9, 2012

Change document library file name programmatically


You must be wondering what is new in this. We can certainly change the name or the title of the document inside document library from code.

Well, no. we cannot do that right away as Name and Title of SPFile are read only fields. As each document is SPFile inside document library we might think that changing name and title field would do the job. But it’s not. Check the below images. Properties are read only.





So what can be done? Well as we all know that each document inside document library is not only SPFile but also SPListItem.

Now these are my shared documents and check the document name.



And let’s re write our code in this way.



And when you execute



I hope this will help.

Friday, April 6, 2012

Hiding Ribbon from SharePoint Page


Wonder how to hide ribbon from any SharePoint page if you wish to. If you have an access on the page and if you have placed a web part on it, then this is the way to hide ribbon.

It’s one simple line of code that does the magic. I am writing it in button click just to demonstrate you.



And you write a code on button.

SPRibbon.GetCurrent(this.Page).CommandUIVisible = false;

Click the button. And you are done.


Wednesday, April 4, 2012

Import SharePoint Designer workflow to Visio diagram


In this post we are going to see how we can import a workflow created inside SharePoint Designer 2010 into Visio diagram and visualize the flow written in the workflow.

If you also would like to read about how we can export diagram created in Visio to Designer 
Workflow, then I would recommend you read Exporting Visio diagram to Workflow Designer as well.

To demonstrate I have created a simple workflow in Designer and it looks like this.



We are pausing until some date and then checking a condition and based on condition we perform an action.

So let’s go ahead and save the workflow. Click on export to Visio option in ribbon under Manage group.



It will ask to save it as Visio workflow Interchange file. This is the same format even when we would like to open Visio diagram into Designer workflow as a name suggest its interchangeable - from one to the other form.



Open Visio and select Microsoft SharePoint Workflow as template and then go to Process group and click on Import button.



The moment you import the workflow created previously turns in to a Visio diagram.



As you can see we first have pause until date, then we have condition of field which is source and then we have send email activity only if condition is true, if condition is false we directly end the workflow. 

As you can see that this diagram is easy to understand from an end user point rather than looking at Designer workflow and wondering what is going on. 

Monday, April 2, 2012

Export Visio diagram to SharePoint Designer workflow – Part 2


If you have not gone through Part-1 of this series I would recommend you reading part-1 first and then continue reading from here.

We have now saved the diagram and its time to export it to the SharePoint Designer 2010 workflow. Click on the export button on the ribbon from process tab.




Save it as Visio workflow interchange format file.



Now open SharePoint Designer 2010 and connect with the site and click on workflows. Then click on Import from Visio button from the ribbon.



Locate the interchangeable file that we saved earlier and open that file.

Now in next screen, it asks us to attach it with the list, name of the workflow and select if it’s a reusable workflow.



Click on finish and you get all the conditions and actions already been set up based on the Visio flow that we created.



Only thing that is pending is set up parameters in the workflow and we are good to go with the workflow.


Also read Importing SharePoint Designer Workflow to Visio

Result is out

Hi,


The result is out



Wednesday, March 28, 2012

Export Visio diagram to SharePoint Designer workflow – Part 1


We saw how we can use Visio web access to display Visio diagram in the browser and even the client does not have Visio client then also they are able to view the diagram in the browser via Silverlight and that too with interactivity with the base list.

Read Visio services series.

There is one more advance feature available for Visio premium and that is the Visio diagram that can be exported to SharePoint Designer.

If we consider a business scenario, then drawing diagram is something that most of the people would love to do and as a business analyst knowing the requirement of a client for certain purpose can certainly draw a Visio diagram.

Once a diagram is ready, it can be handed over to the developer or site administrator which can take it forward to build a meaningful logic that actually works in SharePoint site.
So let’s dive into this series of creating Visio diagram and then exporting it to SharePoint Designer 2010 to make it functional.

Open up Visio premium 2010.

Click on flow chart diagram and then Microsoft SharePoint Workflow and select Metrics Unit and then click on create.


Workflow diagram consists of three groups. One is actions, the other is conditions and the last one is terminators

Any Visio diagram that needs to be converted to SharePoint Designer workflow must start with start indicator and end with stop terminator.

So let’s open up the last group and drag both start and stop terminators to the diagram.



Let’s start with setting a filed and then compare document field and drag it to the diagram. Set a field and compare document field can be found it under action and conditions group respectively.



We have now included the condition and hence always have yes or no logic associated with that. So we need to add two actions to the branch. First let us add do calculation action and send email action.



Now we need to specify which branch will get executed when condition evaluates to true and which when false.

First attach all the connectors between shapes and now select the upper connector with the condition and action and right click to get an option to set branching logic.





And then same way to the lower branch.



So at the end you should have something like this



Save the file. We are ready with our simple workflow and ready to take it to the SharePoint Designer.  Read Part-2 for further reading.

Monday, March 26, 2012

Tasks list Visio diagram


Tasks list in SharePoint 2010 has got one new feature. When we are on a tasks list you can now see that there is an option on ribbon bar with create Visio diagram.

This is a great new feature that allows exporting the tasks data to Visio diagram and having that task list connect with that to see the changes that happens in the tasks list.

If you have fix set of tasks that are assigned to individual person who performs those tasks, then you can have a better look at those tasks by using this Visio diagram than to look at row data in the tasks list.

Yes one important thing to consider here is you must have Visio client if you wish to use this functionality.

Here I have tasks list and several tasks assigned just to demonstrate you.


Here I have some data with assigned to and task priority and task statuses.

Now clicking on create vision diagram will get us Visio diagram. Once the diagram is created, then you can see that you can have a look at the diagram in different ways.

1)    Through status
2)    Through workload distribution
3)    Incompleted tasks assigned to
4)    Workflow status

These options give us better visualization than looking at row data.





Same way you can explore the remaining two options. It also gives you an option to include more fields in the diagram from tasks list if you wish to see them also in diagram.



This diagram is connected with tasks list. Any changes into the items which are mapped with tasks list will automatically reflected in this diagram each time you open, manually click on refresh or set auto refresh.

Thursday, March 22, 2012

Converting document format from browser


Conversion timer job allows us to convert one document to another. As we have seen in previous posts. If you have not gone through previous posts I would recommend you reading them first and then continue reading from here.

Open the document library in which you would like to convert a document format.
I have shared document which I have opened up. When you select a document to convert and then open up the ECB menu, point to the convert this document



And then it asks you to convert a document to aspx page (a webpage). It allows us to configure certain options at that time. Make sure that the publishing feature is activated at this time otherwise it won't allow us to convert the document to a web page.



Click on create and then wait for few minutes if you have selected an option or else after few minutes you can go to pages library and can see that the word document has been converted to the aspx page.



Now what we are trying to do is to use ribbon convert document functionality. However it seems that it is uncovered topic in many of the web sites and not sure as how to use it and how to configure output library etc. We are still working on it.



If you get a chance to work on this feature, do let us know and we would share it with your name mentioned in the post.

Monday, March 19, 2012

Document ID in SharePoint 2010


We all have heard a lot about document ID feature in SharePoint 2010 and wonder what this feature actually does.

Well let me tell you this, this is one of the welcome features from SharePoint 2010. If I have to tell you in a single line what this Document ID can help us with is that it can simply solve our problem with the document URL link.

When we turn on the feature Document ID which is at site collection level scoped feature every document uploaded in site collection gets document ID associated with it.

The advantage is even if you move a document from one location to another location throughout site collection, ID of document remains the same. This gives us an advantage over a broken link URLs for the documents.

Let’s say that you have uploaded a document in a document library called Projects Document. And then you have decided to move that document to some other library called Departmental Repository. So the document now does not reside in projects library but in departmental repository. If you have given a URL to many users to access your document and if they have the old link all they will get it page does not found because document actually does not exist now.

SharePoint 2010 has come up with a new URL associated with Document ID. So first think go ahead and activate Document ID feature and then from the site settings go to the Document ID settings.


You can then configure the document ID to start with certain characters and also if you would like to configure it for all existing documents inside the site.



Remember the there is a timer job called Document ID assignment job that does it. So it might take a while to generate Document ID for documents.



And there is one more service Document ID enable/disable job. This created a column called Document ID in library.



Once we have the Document ID then we can use this new URL to send to users.



Right click Document ID and go to properties. Check out the URL and use that URL in the browser URL and enter. You get the document.




{site URL}/_layouts/DocIdRedir.aspx?ID=DCMT2012-3-31

The advantage is even though document has been moved to any other library across site collection, user still would be able to get the document and as a result will not get broken link URL.

Because we had also enabled Document ID enable/disable job, we also have a field in document library called Document ID associated with each document and of course the ID field which is the base for auto generating Document ID



I hope you must have got the idea now that it's a welcome feature and really a useful when the link to document is broken.


Read more about how can you generate custom Document ID in SharePoint 2010.

Thursday, March 15, 2012

Document set Part – 5


If you have not gone through part-1 to part-4, I would recommend you reading them first and then continue reading from here on.

In this post, we are going to do the same stuff what we did in part-4. So open up SharePoint Designer 2010 and connect to the site.

Go to the list and libraries and find the Shared Documents. You may have a different library. I have document set in shared documents hence I have chosen shared documents.

Go to workflow and create a new workflow. I am showing this just to demonstrate the concept, the real scenario may vary and you need to use the conditions and workflow accordingly.



Now set a condition which is true and we will start the workflow on document set. We will first start with capturing the version.



Open up the actions menu and select capture the version of document set. Provide comments and major or minor version input. Save and publish the workflow. Go back to document set and run the workflow and see that we now have new version captured for the workflow.





Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com