Tuesday, February 28, 2012

Enable BCC in SharePoint Designer 2010 workflow


In SharePoint Designer 2010, when we want to send an email, we can use send an email action in the designer workflow. If we want to keep someone in BCC then we do not see that field appearing in the email configuration dialog.



However if you observe, there is one option on the ribbon with advanced properties, click on advance properties and you get a dialog where you can also configure BCC field.



Hope this helps.

Monday, February 27, 2012

Variations in SharePoint 2010


Variation was also a part of MOSS 2007and now is also a part of SharePoint 2010 with some added features.

Variations are used when we would like to create multi lingual SharePoint sites. There is not much information available about variations but I will try to cover as much as possible.

You can find variation settings under site collection settings. Variation, Variations labels and variation log.


Variation operations execute on the back ground timer jobs in SharePoint 2010. If you see under Job definitions in Central administration, you will find different jobs running for variations.


We here need to create variation labels and hierarchy and define the source site and then these settings for variations will be replicated for all targeted sites.

Variations can also be set programmatically. We have not explored this very much however whenever we get a chance to explore this, we would love to post it one more time with more information with example.



Thursday, February 23, 2012

Edit control block and site actions menu programmatically

Hi,


Here is how you can set edit control block on specific list and extend site actions menu by including a custom option in that.


This is equivalent to what we do with customactions tag via feature deployment.


This is simple button click example to achieve these two functionality


This is only for demonstration purpose. Write a logic in your own way.



     protected void btnAddCustomAction_Click(Object sender, EventArgs e)
        {
            SPWeb currentsite = SPContext.Current.Web;


            #region "Add custom action to a specific list"


            SPList lstOrders = currentsite.Lists.TryGetList("Orders");         


            if (lstOrders != null)
            {
                currentsite.AllowUnsafeUpdates = true;


                if (lstOrders.UserCustomActions.Count > 0)
                {
                    foreach (SPUserCustomAction action in lstOrders.UserCustomActions)
                    {
                        if (action.Name == "Google")
                        {
                            action.Delete();


                            lstOrders.Update();


                            break;
                        }
                    }
                }             
                        SPUserCustomAction customaction = lstOrders.UserCustomActions.Add();
                        customaction.Name = "Google";                
                        customaction.Location = "EditControlBlock";                
                        customaction.ImageUrl = @"\_layouts\IMAGES\CustomImages\google_logo.jpg";                        
                        customaction.Url = "https://www.google.com";
                        customaction.Sequence = 1000;
                        customaction.Title = "Google";                
                        customaction.Update();
                        lstOrders.Update();


                        currentsite.AllowUnsafeUpdates = false;
            }


            #endregion


            #region "Add custom action to a web"


            if (currentsite.UserCustomActions.Count > 0)
            {
                foreach (SPUserCustomAction action in currentsite.UserCustomActions)
                {
                    if (action.Name == "GoogleOnSiteAction")
                    {
                        currentsite.AllowUnsafeUpdates = true;


                        action.Delete();


                        currentsite.Update();


                        currentsite.AllowUnsafeUpdates = false;


                        break;
                    }
                }
            }


            currentsite.AllowUnsafeUpdates = true;


            SPUserCustomAction customactiononsiteactions = currentsite.UserCustomActions.Add();
            customactiononsiteactions.Name = "GoogleOnSiteAction";
            customactiononsiteactions.Location = "Microsoft.SharePoint.StandardMenu";
            customactiononsiteactions.Description = "Takes you to a google site";
            customactiononsiteactions.Group = "SiteActions";
            customactiononsiteactions.ImageUrl = @"\_layouts\IMAGES\CustomImages\google_logo.jpg";
            customactiononsiteactions.Url = "https://www.google.com";
            customactiononsiteactions.Sequence = 2000;
            customactiononsiteactions.Title = "Google";
            customactiononsiteactions.Update();
            currentsite.Update();


            currentsite.AllowUnsafeUpdates = false;


            #endregion


        }

Wednesday, February 22, 2012

Result is out

The result is out and it seems that people are giving Windows Apollo thumbs up.


Monday, February 20, 2012

Document Library count differs from actual items



Today I faced a strange situation where when i went to see total number of items inside a document library and total items shown on the viewlsts.aspx page differs.


I went to check the items inside document library.There were four folders and inside them there were documents. Now when I saw all those folders and files inside it, total count came to 39 and the viewlsts.aspx was showing me 45 items.


What can be the reason? Where are remaining documents? Well, the answer is very simple and a logical at the same time.


When you are working with publishing site and when you are writing any document but still in draft mode then that document is also counted as a part of library but will not be shown inside library as it is not yet published.


So I went to a document library settings, checked Manage checked out files under permissions and management and bingo I found the remaining 6 documents who were still in draft mode.


Now the total matches. Hope this interesting finding help you.



Thursday, February 16, 2012

Integrating Facebook comments into SharePoint


Here is an interesting topic. Almost all of us have Facebook account. What if you would like to post a comment in your blog site or even in to a team site without posting it as a network windows account.

Seems to be an interesting topic right? Well yes, and the answer lies in Joels Oleson’s effort. We would like to thank Joel for creating such a fantastic functionality.

You can find the WSP here. 


The advantage is it’s a sandbox solution, so even you do not have to depend of farm administrator to install it for you.

Now I assume that you have deployed that WSP in the solutions gallery and activated.

Go to a page where you want to have this web part shown. Edit the page and add web part. You will find under social collaboration section a web part called FBCommentsBoxWebPart. Add that webpart to a page.



The moment you add a web part, you get something like this and then you would be able to add comments using different social media.

I hope this will help many and you will use it whenever possible.





Monday, February 13, 2012

Original title of list or library


Have you ever noticed while coding when you have changed the name of the list and then we you refer the list.title property, all you get is the new name.

Yes, that is how it should be. You must be wondering what the big deal in this is. Well, here is a catch in that.

When you write or call any method or property that returns the list items path URL or document URL, you still will get the old name of the library.

Here I have one library called Orders.

In a button click, I have written a code to change the name of a list. you can do this even from UI by going to list settings and changing the name.


protected void btnNameChange_Click(Object sender, EventArgs e)
        {
            SPWeb currentsite = SPContext.Current.Web;

            lblTitle.Text = string.Empty;

            SPList listOrders = currentsite.Lists.TryGetList("Orders");

            if (listOrders != null)
            {
                lblTitle.Text = listOrders.Title;

                listOrders.Title = "Orders New Title";

                listOrders.Update();
            }
            else
            {
                lblTitle.Text = "Orders list does not exist";               
            }
        }

Now we have a new title of the list.


Let’s click the button again.



See now we have got a message that list does not exist because we have changed the name of the list. So in this situation, what one should do if you already have code written which fetches a name of the list and perform an action on it at many places?

Are you going to rewrite your code at all the places? Think on this and you’ll get an idea how difficult this can be.

So here is a solution to this. Answer is very simple use rootfolder property of a list that always gives you original name of the list.

Let’s change a code a little.

  protected void btnNameChange_Click(Object sender, EventArgs e)
        {
            SPWeb currentsite = SPContext.Current.Web;

            lblTitle.Text = string.Empty;         

            SPListCollection lists = currentsite.Lists;

            Boolean IsNotFound = true;

            foreach (SPList list in lists)
            {
                if (list.RootFolder.Name.ToUpper() == "ORDERS")
                {
                    IsNotFound = false;

                    lblTitle.Text = "Original Title:" + list.RootFolder.Name.ToString() + " and Current Title " + list.Title;

                    list.Title = "Orders New Title";

                    list.Update();

                    break;
                }               
            }

            if (IsNotFound)
            {
                lblTitle.Text = "Orders list does not exist";  
            }          
        }

And here is what you get


Hope you must have found this useful.








Wednesday, February 8, 2012

Reusable workflows in SharePoint 2010 – Part 2


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

Now open the SharePoint Designer, connect with your site and click on Reusable Workflow.



Select document content type, here we can select the content type on which we would like to attach the workflow to.


Now check the condition, that if the current field is equals to department category and compare that with Marketing then log to history that marketing was selected.


And I have then put if else condition for each department.


Save the workflow and then publish the workflow.

Now it’s time to associate this workflow with the content type. Being on the same workflow settings page, click on associate to content type option from ribbon.

When you click on it, the browser window opens which allows you to associate. Select start this workflow on item adding.


Once you create a document using the template, and when you save it, you can see the workflow has triggered and then completed by saving the right information in the workflow history list.










Monday, February 6, 2012

Result is out

Finally the result is out

and it seems that people think PCs will never die and some think that it will still take another 4-5 years.



Wednesday, February 1, 2012

Reusable workflows in SharePoint 2010 – Part 1


A long awaited feature has finally come to the SharePoint 2010 and the feature is reusable workflows. In earlier versions we could not create reusable workflows.

We now can create reusable workflow for a content type. Yes, there is one limitation which is we can create a reusable workflows only for content types. So when we add content type to list or library we get the workflow along with it which has logic attached to it.

We will see that in action. First we will create a content type, add that content type to list, then we will create a very simple workflow of course a reusable one which is attached to the content type that we will create and then we will see how that works with workflow in a library.

So go ahead and open SharePoint designer 2010. I am first going to create a site column and content types can only contain site columns.

Click on New site column, I am selecting Choice column and giving name and assigning to a new group and add some data to it.




So now we have site column in our site and we will now create content type.


Now create a new content type.


Now you can find it to the custom group that we gave

Now click on content type and go to its settings page


Click on edit content type columns and then click on add existing site columns from top left


And then select our site column to include the column in the content type.


Keeping the content type settings page open, click on administration web page from where we will associate document template with this content type.


Click on advanced settings, upload a document template. So now we have associated a document template with this content type.

Now is the time when we will add this content type to the existing document library.
Go back to designer, in all lists and library open the library on which you want this content type to be added.

Once the library opens, click on content type settings and add the department category content type to it.


Now we have that document template available in the library. To see that you can open this in browser and then see the library all items page and click on New.



Read Part-2 for further reading.




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