Monday, March 15, 2010

MOSS 2007 Excel Services - Part 1

Excel Services !
Its one of the most powerful feature of MOSS 2007. But have you tried to have a look into it?
If not , this article explains you the basic steps required to get hands on experience with Excel services. What all is required is listed below:
1. Shared Service Provider (SSP).
2. Excel file
3. A MOSS site
4. Document library
So now if you have created all of the above components, lets start….

STEP 1 : Making the document library trusted in central admin

In order to work with excel services, you need to make the document library where you are going to keep an excel file declare as ‘trusted’ in the central admin site.
Open the central admin site and click on the SSP name. In this case, the name of SSP is MySSP. Click on Excel Services Trusted File Locations and add a new trusted location. Mention URL of the document library in the site where you wish to keep the excel file. Keep rest of the settings as it is and click on OK. Refer to the screenshot below:



STEP 2: Configure settings of the document library

Open the document library where you want to keep the excel file. Go to settings à Advance Settings and as shown in the screenshot below, find the option ‘Opening browser - enabled documents’ and select the option ‘Display as a web page’ . Press OK to complete the step.





STEP 3 Publishing file to the document library

There are two ways to store the excel file in the document library.
a. Uploading the file directly to the library.
b. Publishing the file to the library.
As we all know how to upload a document to the document library, I would like to explain the other way.
Open the excel file and open the option of file menu as shown in the figure below. Select publish and then Excel Services. Specify the URL of the document library and that’s it. The excel file will be published or uploaded at the specified location. Of course, no need to mention that you need to have permissions on that library for uploading.







STEP 4 : Start of the excel calculation services

In order to view an published excel file, the ‘Excel Calculation Services’ needs to be running. You can start the service by navigating to Central Admin à Operation à Services on server and start this particular service.






That’s it. You have successfully completed the basic hands on for working with excel services. To see what is there in the excel, click on the title of the excel you published in the document library. Intended result is that it will open in the browser itself displaying the data in excel format.
More hands on and information on excel services coming in subsequent posts.
Contributed by 'The Ace'
Read More…

Creating custom activity in Workflow Part – 4

Hi All,

As we are approaching to some final posts of the series, I feel happy to share these posts with you all and make you aware of all things related to custom activity.

If you have not read previous articles, I recommend you reading Creating custom activity in Workflow Part – 1 First.

Here in this post, we will talk about the visual designer for the custom activity. It has nothing to do with functionality, so definitely this is not something which is required, However it is something which is nice to have.

So let us go ahead and understand how we can create visual appearance of custom activity.

By default when you drag and drop any activity, you will observe the shape and coloring same for each and every activity. We can change the shape, background color, border of our custom activity to give new fresh look. Hence I refer this visualization change of custom activity as makeup of activity. (Remember I used this term in post 1). :)

To achieve this, we need to implement three steps instead of two steps like other posts that we did.

1) Create a class which inherits from ActivityDesigner.
2) Create class which inherits from ActivityDesignerTheme.
3) Add ActivityDesignerTheme attribute to the class which inherits from ActivityDesigner.
4) Add Designer attribute to the Custom activity class.

So let’s start. Add one more class to our custom activity project. Name it CustomActivityDesignerTheme



Then add CustomActivityDesigner class which inherits from ActivityDesigner and add attribute as shown in figure below.



And then add designer attribute to the Custom activity class.



Now again just compile whole custom activity project, add activity to the console application and see the result. You will see our customized theme for our custom activity that we’ve just created.


Read More…

Friday, March 12, 2010

How to hide breadcrumb on single page in SharePoint

Hi All,

May times we require to hide bread crumb on single page. Say you have created one web part page in one document library and when you visit the web part page, you will see your site->document library->web part page name.

And you do not want your user to click on document library and see the content in it.

Hence we can place one content editor web part on the page and write down following code. This will remove the bread crumb from the page.

I am creating one demopage.aspx under shared document library.



You can observe bread crumb, where user can click on it and go to the shared documents.



Now add one content editor web part and add the following code into.

<style rel="stylesheet" type="text/css" />
td.ms-titlearea { display:none; }
</style>


Just make sure that you set chrome type to none under appearance.

Simple, see the result. Bread crumb is no more on the page.



That's it. Your job is done.
Read More…

Wednesday, March 10, 2010

Creating custom activity in Workflow Part – 3

Hi All,

In last two articles, we saw how to create basic activity and how to work with validations of properties.

If you haven't gone through previous parts, then i recommend you reading Creating custom activity in Workflow Part – 1 and Creating custom activity in Workflow Part – 2 post before continue reading here.

In this post, I am going to talk on Tool box item with respect to custom activity. When we want to initialize properties or want to perform any action when activity is being added (dropped) on visual designer, we can use toolbox item for this.

To achieve this functionality we have to implement two steps.

1) Create Toolboxitem class for custom activity deriving from ActivityToolboxItem class.

2) Add ToolBoxItem attribute to the custom activity class.

These two steps shown above are basic steps that you will find in all parts of this series. Because we have to perform above same steps (just inheritance is a difference) to achieve stuff for custom activity.

So let us go ahead and assign default birth date to our birth date property (I know it does not sounds anything practical, However as I said if we use simple example then it makes life easier).

One more important point to mention here is that we have to mark our class serializable and also we have to call deserialze in the constructor of the class. Reasons for this, well it is a topic of its own. I will explain it later. As of now, we will implement them to demonstrate our example and anyhow it’s merely two-three lines to write.

Go ahead and add class to our custom activity project. Name it CustomActivityToolBoxItem.



Then, go to the custom activity class and add System.ComponentModel which will help you to add attribute to the class.

Add the newly build assembly to the toolbox and drag and drop on visual surface and see the magic. You will see default birth date property being set by our code.



See you soon with part 4.
Read More…

Monday, March 8, 2010

Creating custom activity in Workflow Part – 2

Hi All,

In my first post Creating custom activity in Workflow Part – 1 , we discussed about creating basic custom activity. Now as promised in this post, we will move a bit and hit the second topic of validation with custom activity.

When we gave input of birth date in first activity, we didn’t create any validations for it. This post will tell us how to create validation that will help us to validate the input user is providing to the parameters. So we will force user to provide correct birth date.

Bottom line is we can use the validation techniques in custom activity for each parameter that we define for our custom activity.

Adding validators consist of two steps.

1) We have to create a class which inherits from ActivityValidator Class.
2) Add ActivityValidator attribute to the custom activity class.


We have to override Validate method and we will return ValidationErrorCollection which hold all validation errors for birth date.

For validation logic, we will simply try to validate date against regular expression and if not matched, then we will throw the Error from our validator class.

Keep in mind that we are using the same custom activity that we’ve created in part 1. Hence if you haven’t gone through part 1, I recommend read it first and then carry on with this example.

So go ahead and add one class to the Workflow Custom activity project and name it CustomActivityValidator and inherit with ActivityValidator.



And then go to Custom Activity class and just add one attribute there on top of the class line and also add System.Workflow.ComponentModel.Compiler using statement.



Now just build the custom activity project again, and remove the previous custom activity on our console project and drag new (modified just now) activity to console application, and try to enter invalid date in property and valid property, and see. First we will enter valid date and then invalid date.





Read Creating custom activity in Workflow Part – 3 for furher reading.
Read More…

Friday, March 5, 2010

Creating custom activity in Workflow Part – 1

Hi All,

After long time, I am back to the workflow and really I have spent many months without writing anything related to the workflow.

See Creating custom activity in Workflow Part – 2 for further reading after reading this post.

This post will talk about creating custom activity in workflow. Is this the right time to talk about this topic, when you have bunch of articles already written on the net and books. Well, I think almost all of them starts with complex example of creating custom activity. Even in some books, they start with complex example, never written simple examples.

So I thought of giving a change to myself to write down very basic stuff and example about custom activity.

Custom activity in workflow is just like the concept of creating custom control for .Net applications. It can be user controls or a custom control. In the same way, in workflow world it can be single activity (Basic activity) or composite activity. Creating single activity is somewhat easier than creating composite activity. For example, Delay is basic activity and While is a composite activity.

Other one important point to remember is basic activity derives from System.Workflow.ComponentModel.Activity and composite activity is derived from System.Workflow.ComponentModel.CompositeActivity.

An activity is made up of four components. All are not required, only definition is required for an activity. However definitely we want to execute something in that, hence executor is also important.

1) Definition: This is the definition of an activity where we define properties, events etc.
2) Validator : This is for validating input properties value.
3) Executor: Execute the actual code in the activity.
4) Toolbox: This will help us to assign default values to properties at the time of dragging on Visual Studio designer surface.
5) Designer: This is about makeup of the activity. (You will say, yes definitely a makeup :) )

We will see each one of them in different parts. We will start with part 1 in this post and continue to explore each option in series.

So let us go ahead and start writing our basic code to create custom activity.

First open visual studio and choose workflow under C# and then choose custom activity. Add a class and perform the following steps. As we are creating basic activity, we will inherit from Activity class.

Make sure that your class is marked public; otherwise you will not be able to place activity in toolbox itself.

We have to create one dependency property and we are going to create BirthDate property here and our basic activity will return the age of a person.

Then we will override the Execute method and execute my logic and then we will return our ActivityExecutionStatus, that means if it succeeds, we will return closed and if not, we have to return Faulting.






Now go ahead and add one more sequential console workflow project to existing solution, and click on choose items on toolbox, browse to the DLL of just created custom activity and there you go, you will have it in the toolbox, just drag and drop it on the surface. Enter the BirthDate in BirthDate property, we’ve created.



Run it, Debug it, try it and see for yourself.



I will be back very soon with part 2.
Read More…

Wednesday, March 3, 2010

Finally the result is out

Hi All,

Again thank you for your support in giving opinions about polling questions.

We asked about new ribbon control of SharePoint 2010 and almost people have welcomed this change.

Question was :

How do you see new ribbon interface in SharePoint 2010?

Options were :

1) Welcome change in SharePoint 2010. Making consistent with office product.
2) Have they really changed anything? It is just a way of presenting options differenty.

Here is a result.

Read More…

Tuesday, March 2, 2010

Version difference in Site Settings and Central administration

Hi All,

One day somebody asked me, what is the version number of your SharePoint? And I did not have answer because I was not too sure where to look for. However it came in my mind that we can see version number on site settings page. Hence I opened my site settings page and gave answer to a person who asked me last evening.

So what is the big deal here in version number? Nothing new, you just have the version number of your SharePoint on site settings page.



Wait a minute. Have you ever observed version number as part of Farm Information in central administration. See below image for it.



In my machine, version number under site settings and version number under farm information are same. However, if you see a different version number in any of them, then there could be some reason for this. May be following reason is responsible for this version difference.

1) You may have applied some service packs related to MOSS / WSS 3.0 and you forgot to run SharePoint technology and configuration wizard. You must complete that wizard after applying service pack and that too successfully.

So bottom line is whenever you apply any service pack or when ever SharePoint asks you to run the wizard, just run it successfully and you should have same version number under both above mentioned screen.
Read More…

Thursday, February 25, 2010

Taking list item back up with attachments

Hi All,

Sometimes we require taking back up of list items along with attachments. Definitely there is an option to export to excel, however that doesn’t copy attachment with it and hence it is a drawback only if you want attachment with list item as well, else export to excel is really a cool functionality.

Coming back to the point, so what do we do to get the attachment as well? Well, the answer to this question lies in the same menu and that option is Open with Access.

So go ahead with your list items that you want to back up. Open the Actions menu and click on open with Access.




Specify a new location for your database and also chose whether you want to be connected with SharePoint list so that any changes can be reflected here and also vice versa, or just you want to have a copy of it which is export the data.



That’s it. You have just taken a back up of your list items with attachments.
Read More…

Tuesday, February 23, 2010

Set audience targeting programmatically

Hi All,

Today I am going to explain you about audience targeting. However I am going to share in terms of programming aspects. Because we all know that we can create our audience in central administration and then simple apply them on list items or document library items or on web parts on pages.

However we will see it this time how to do the same using code.

I assume that you have already created audience named “Sales” and “Finance”. I am not going in deep discussion explaining you each and every class and methods used in it. You may query me your doubts and I will be keen to reply you back.

using (SPWeb objsite = (SPWeb)properties.Feature.Parent)
{
using (SPLimitedWebPartManager wpm
= objsite.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared))
{
AudienceManager am = new AudienceManager(ServerContext.Current);

wpm.WebParts[0].AuthorizationFilter
= string.Format("{0};;;;", am.GetAudience("Sales").AudienceID);

wpm.SaveChanges(wpm.WebParts[0]);
}
}


We first take our web context and then take out the default.aspx web parts. We use webpartmanager to deal with them. Then take out Audience manager class with the context, and then interesting part comes. Authorizationfilter takes argument in such way that we have to pass ;;;; in it after getting the audience target ID. Get the webpart that you want and pass its Title let’s say in wpm.WebParts[0].AuthorizationFilter line. I’ve used 0 just to get the first webpart and show you the demo.

Here we want to target sales people, so we have passed Sales and get the ID of it and finally call up the savechanges method of webpartmanager object.

As simple as that.

Hummm…What about Finance people. Well there you go, you can set multiple audience in one go.

Just change the line to.

wpm.WebParts[0].AuthorizationFilter
= string.Format("{0},{1};;;;", am.GetAudience("Sales").AudienceID, am.GetAudience("Finance").AudienceID);

Your job is done.
Read More…



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