Tuesday, July 22, 2014

Showing Picture with hyperlink to open link in a new window

Showing Picture with hyperlink to open link in a new window


There are many ways to achieve this functionality –

Adding a Content Editor WebPart and Pasting the following code as mentioned by David Lozzi in his blog:

 

Another way is to create a Site Column of type “Image with formatting and constraints for publishing” in the root site collection. Once you have created this site column, you can add it to any existing list/ library and then at the time of adding an item you can just use this property to add a picture with hyperlink and if you set “Open in a new window” property for the newly added site column, the link will open into a new window.


Thursday, June 19, 2014

How to download all the photos from a dead old giant named ORKUT!!!

Copy - Paste from the following url:
https://support.google.com/orkut/answer/3220186?hl=en

In order to download your Orkut information, you must be the owner of the account. Some Orkut information can be downloaded using Google Takeout in a single ZIP file containing HTML files and JPEG photos.
You can download these items from Orkut:
  • Your profile
  • Scraps received
  • Testimonials received
  • Activities
  • Your photos
Note that you can only export the testimonials and scraps you have received and their comments.
To download your Orkut information:
  1. Go to the Google Takeout page.
  2. Click Choose services and then select Orkut.
  3. Click Create archive.
  4. Wait for the archive to be ready. It may take some time. Optionally, you can be warned by email when it's ready.
  5. When it's ready, click download.
There's no limit on how many times your Orkut information can be downloaded.

Status Indicator webPart not showing status icon

Today I created a SharePoint list (say XYZ) and then a Status List. Then in the Status list I added the SharePoint list XYZ by selecting New > SharePoint List based status indicator. It was working as expected.
Next I went to the Home page of my site and as per the requirement tried to show the current status by editing the page and then adding the Status List WebPart there. But as soon as I finished adding the Status List as a webPart, I noticed the Status Indicator was not showing up. I created new views, changed different settings but of no use. Soon I realized there must be a different way to show the status in the webpart. And that way is to use Status List webPart or Indicator Details webPart from under the Business Data webPart category. Once you add either of the above into the page, it is going to tell you to 'Open the tool pane' to configure it. In the tool pane select your Indicator List i.e., your status list and select Apply > OK and you are done! Save the page, check it in if necessary and now you will see the status icon showing up in your desired page.

Cheers,
Avik

Wednesday, June 11, 2014

ItemUpdating event receiver throwing error - 0x81020015The file has been modified by ...

Few days back I tried to create an event receiver on a SharePoint Library which is going to fire whenever somebody adds a new record. At the time of adding the record the event receiver was supposed to add the logged in users name into a custom column. But to my great amusement it started throwing the following error:

0x81020015The file XXX has been modified by...


Unfortunately I was not able to fix it and after doing a lot of RnD was not able to find a conclusive solution.
It looks like a read/write lock problem and I was not interested in sending a thread to sleep. So I changed my logic a little bit and started implementing the same logic in Item_Updated event. So if you face the same error, then if Googling doesn't help you much, then I will suggest to tweak the logic and use Item_Updated event! Sorry!

How to show values on mouse hover on a graph present in SharePoint Chart WebPart

To show values on mouse hover on a graph present in SharePoint Chart WebPart, do the following:

1. Add a Chart Web Part from Business Data Category
2. Select the Date and Appearance link present on the newly added Chart webPart
3. Select Customize your Chart
4. On the left side Chart Customization Wizard, expand Step 3 and select Hyperlinks and Tooltips
5. On the Series Tooltip box enter #VALX [#VALY] and select Finish
6. Stop Editing or Check In the page

Now hover your mouse on the graph and you will see value at those point in X,Y manner.

Monday, May 12, 2014

"PowerPoint Web App encountered an unexpected error" - Getting this error?

Few days back an end user of my organization started getting the the following error whenever she tried to open any PowerPoint presentation after clicking the link from within any SharePoint document library:


Initially we though it is related to Office Web App feature, but after checking all the features and permissions we were not able to find anything wrong. When we were out of options, we found out that the user has ran the Software Upgrade Suite and then we noticed she was using IE 9 64 bit. Then we thought to try it in a 32 bit version of IE and voila! So if you are also experiencing the same issue, try it on a 32 bit browser!

Thursday, August 11, 2011

Assigning SharePoint List Item level permission programmatically


To add item level permission in an SharePoint List or Library, you need to keep three things in mind:

You have a valid SPUser object in your hand
You have to break the role assignment inheritance for the list
You have to add Role Definition and Role Assignment to the targeted list item

Though above statements looks complicated, don't think much about them – just use following two functions wisely and you are done :)

Assumption:

1. You have SPListItem object in your hand
2. You have a valid SPUser in your hand

Working:

First call the below method and pass the SPListItem as the input parameter:

RemoveAllPermissions Function
  1. private static void RemoveAllPermissions(SPListItem CurrentlistItem)
  2.         {
  3.             //The below function Breaks the role assignment inheritance for the list and gives the current list its own copy of the role assignments
  4.             CurrentlistItem.BreakRoleInheritance(true);
  5.             //Get the list of Role Assignments to list item and remove one by one.
  6.             SPRoleAssignmentCollection SPRoleAssColn = CurrentlistItem.RoleAssignments;
  7.             for (int i = SPRoleAssColn.Count - 1; i >= 0; i--)
  8.             {
  9.                 SPRoleAssColn.Remove(i);
  10.             }
  11.         }

Next call the below method and pass the desired parameters:

GrantPermission Function
  1. private static void GrantPermission(SPListItem CurrentListItem, SPWeb oSPWeb, SPRoleType SPRoleType, SPPrincipal SPPrincipal)
  2.         {
  3.             try
  4.             {
  5.                 //Create one Role Definition i.e Full Controls, Contribute rights or Read rights etc.
  6.                 SPRoleDefinition oSPRoleDefinition = oSPWeb.RoleDefinitions.GetByType(SPRoleType);
  7.                 //Create one Role Assignment for the specified SP user or group.
  8.                 SPRoleAssignment oSPRoleAssignment = new SPRoleAssignment(SPPrincipal);
  9.                 //Bind the role definition to the role assignment object created for the user or group.
  10.                 oSPRoleAssignment.RoleDefinitionBindings.Add(oSPRoleDefinition);
  11.                 //Add it to the specified list item.
  12.                 CurrentListItem.RoleAssignments.Add(oSPRoleAssignment);
  13.                 //update the list item so that specified user assignment will have the access.
  14.                 CurrentListItem.Update();
  15.             }
  16.             catch (Exception ex)
  17.             {
  18.                 EventLog.WriteEntry("Error in UAR Initiation Workflow", "GrantPermission() : " + ex.Message);
  19.             }
  20.         }

Thats it!!! So simple and so easy.
For your easy reference I am including the code block from where I used to call these functions:
 

How I am Calling them
  1. if (validUsername)
  2.                             {
  3.                                 if (rdr["Manager Logon"] != null)
  4.                                 {
  5.                                     SPUser CurrentUser = mySite.EnsureUser(rdr["Manager Logon"].ToString());
  6.                                     RemoveAllPermissions(item);
  7.                                     GrantPermission(item, mySite, SPRoleType.Contributor, CurrentUser);
  8.                                     SPGroup oGroup = mySite.SiteGroups["UARAdministrators"];
  9.                                     GrantPermission(item, mySite, SPRoleType.Administrator, oGroup);
  10.                                 }
  11.                             }
  12.                             else
  13.                             {
  14.                                 //Admin need to resolve this issue in the list
  15.                                 RemoveAllPermissions(item);
  16.                                 SPGroup oGroup = mySite.SiteGroups["UARAdministrators"];
  17.                                 GrantPermission(item, mySite, SPRoleType.Administrator, oGroup);
  18.                             }

Cheers,
Avik

How To: Hide the Quick Launch in a MOSS Page

1. add a CEWP in the page.
2. Select Source Editor and paste the following code:



















3. Save it then Select Apply- OK in the web part properties window. If needed you can select Web Part Hidden property to TRUE.
4. Bang – You are done.

Cheers,
Avik

Thursday, July 28, 2011

SPUtility.SendEmail - Resolving Mail Body Truncating Issue

If you are using SPUtility.SendEmail() function to send mail and your mail body has quite big statements, then you may find out some part of the mail body is not coming up in the sent/ received mail. This is because of the fact that SPUtility.SendEmail() puts a cap to the length of a single line (Probably 2048 Characters). to resolve this issue, what you need to do is add some newlines after each tag in the body of your email.

Cheers,
Avik

Wednesday, June 29, 2011

Custom Page Addition Baseline Feature for MOSS 2007


After a long break, again came some requirements where I need to work on MOSS 2007. After working with SP 2010 and VS 2010 for more than a year, it is like again going back to the stone age of SP development. So, I thought it will be good to have a base VS 2008 Web Application Solution and a base Feature Template to add custom pages in SharePoint context ready for all the MOSS developers. So, I created one custom solution and feature which you can download and the modify accordingly. This feature is strictly for adding custom pages into SharePoint context and both the solution and feature template can be downloaded from the following link:

Steps:
1. Unzip the folder and build the solution.
2. Place the compiled dll into the GAC
3. Place the feature folder in 12 Hives feature folder
4. Install and activate the feature from STSADM
5. Open a browser window and write down the url in ServerName-PortNo/SiteName/UAR/Default.aspx in this fashion and see our custom page started running in SharePoint context.
6. To add your own custom page, open the solution and add new page there.
7. Once done designing, copy that .aspx page inside our own feature folder.
8. Again compile the solution and place the dll inside the GAC and open the new page in the similar approached defined in point no 5.

Cheers,
Avik