Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.
Showing posts with label sharepoint 2010. Show all posts
Showing posts with label sharepoint 2010. Show all posts

Friday, July 25, 2014

Cross site list view web part anywhere in site collection

Introduction

There are times when you want to display list/library from root level site collection or visa-versa to sub-site but stuck because sharepoint don't provide list view web part that can be shown across sub sites. If you are in same site collection, its possible with the trick I am going to share.

Step 1 - Create a page and drop list view web part there

Create a page in the site/web where you got the list/library and drop the list view web part into that page and save the page.

Step 2 - Export lsit view web part

If you try to see the edit menu for the web part and there is a link called "Export" you can directly export and download the web part.

If you can not see "Export" option in the web part menu, you have to do following:
  • Right click on the web part content heading that shows list/library fields and click on inspect element (IE9+, chrome, firefox and other popular browsers)
  • Once you are ready with web part id, you can use following url to export the web part
http://root-site-url/_vti_bin/exportwp.aspx?pageurl=page-url&guidstring=web-part-guid

Step 3 - Set Web ID

  • Switch to powershell and get guid of the web where the list exists. $w = Get-SPWeb -identity url-of-web;w.ID
  • Open exported .webpart file and find WebID property and set value of the guid you get to the value in WebId node in web part file.

Step 4 - Upload it to web part gallery

  • Go to site settings > Galleries > web part galleries
  • click on upload and upload your web part file here and set title, group and description of the web part

Step 5 - Finished

  • Go to anywhere in your site collection and add the web part. It will show you the list view web part that you uploaded in specific group.

Limitations:

I tested this with list/libraries having html as default view and rendering of the list view web part works. There are lots of functions associated with the list/library that can be performed from ribbon that I have not tested. Please make sure you consider that while using this trick.

Wednesday, July 4, 2012

Not able to change page layout


Problem:​
Due to some problem in page, Page Layout button in ribbon is showing disabled.
Solution:
Use following as QUICK solution if you are creating a new page:
  1. Delete newly created page
  2. Go to site settings > Page Layouts and Templates
  3. Locate "New page defualt settings" and select the page layout that you want to set as default page layout.
  4. Save setting
  5. Create new page
There can be many reasons of Page Laout showing disabled in ribbon. You can reference following links to go deeper and resolve it properly.
  1. Try check out the page and then go to edit mode of the page.
  2. Try different browsers to change page layout
  3. ​Change page layout using powershell
  4. Reference link 1​

Monday, July 2, 2012

SMTP4DEV: Your sharepoint 2010 out going email server for development farm

If you are having standalone sharepoint 2010 development farm on window7 64bit, and looking for good option,  SMTP4DEV. It is a free tool. You will need around 10mins and then you can start receiving emails from sharepoint farm! Here are quick steps:

  1. Download  SMTP4DEV from it's codeplex project site, I prefer standalone exe but you can download installer as well.
  2. If you like to use some custom local domain, click on options and set up some local domain like local.machinename.com. Create host entry pointing to 127.0.0.1
  3. By completing these many steps you can now send emails through  SMTP4DEV by any url ending in @local.machinename.com
  4. Go to sharepoint central administration > System settings > setup outgoing email server.
  5. set local.machinename.com as server, and provide any email ending in @local.machinename.com 
  6. Save your settings
After these minimum set of configuration you will be able to start sending emails. Beauty of SMTP4DEV is:
  1. It will show you notification that new email is sent
  2. It will show you all emails sent from the smtp in UI without actually sending it
  3. You can inspect email
  4. You can view email (in email client that you set default)
So, in conclusion, it is a best choice KISS kind of solution for your sharepoint 2010 development farm's outgoing SMTP server.




Sharepoint 2010: TryGetList vs GetList

As a developer, you will say GetList can throw exception but TryGetList will not. It is actually confusing because TryGetList looks for listTitle and returns null if list is not available at expected location. GetList will expect listUrl and can throw FileNotFoundException or ArgumentException if list is not present at expected location or relative/absolute url of list is invalid relatively. Another biggest difference is they belong to different class!


Apart from all those technical details, I noticed that many sharepoint administrators likes to start with a simple list/library name and eventually change it to make it as close as possible to what they do. That will make list/library url and their names different. Here comes the actual problem. If you are actually using list/library names in your code, it will no longer work. OR we can say you are not allowing sharepoint administrators to change name of list/library that they have created. 


By using GetList you are actually giving them flexibility to use whatever name they like to use, as far as they are not changing url or list/library code will still work.


In conclusion, it really depends on requirements how you are going to deal with the situation but it is good to keep in mind that you can use GetUrl function in your code to allow sharepoint administrators to change their names without worrying about breaking functionality.







Friday, June 22, 2012

How to use soapUI to review ListData.svc


Introduction

​SoapUI is a free tool that can be used to test out of the box ListData.svc service provided by sharepoint. This service is available at /_vti_bin/ListData.svc for any of your sharepoint site. Here is how we can try it out using SoapUI.

Step 1: Install sopa UI and click on File > New SoapUI Project. Add some project name and check "Add REST Seervice:" like shown in following figure and then click OK



Step 2: After clicking on OK another window will open like following, just click on OK




Step3: New REST resource window will appear. In resource name enter site url and in resource path/endpoint provide list/document library name and click on "Extract params" button. Following is the screen that shows sample data.




Step4:That will automatically create a new request called Request 1.This request will automaticlaly detect endpoint and path to your list/document library. If it is not, just click on"-no endpoint set-" and click on add new endpoint. Enter site url in the dialog again.



Step5: Maximize "Request 1" window in soapUI. In botton left corner you will see " ... ", click on it and you will be able to provide sharepoint authentication details there.



Step6: Once you are done with authentication details you can click on execute icon at top left corner of "request 1" window (marked in above figure) to execute the request and you will be able to see response at right hand side window.

Step7: ListData.svc can also return json data in response out of the box. Just try to provide accept = application/json like shown in figure below:


Conclution:
SoapUI is a super simple too to try out and it will be really help to review xml/json data while you are planninig to consume it with jQuery. 


Monday, May 28, 2012

CAML Designer: Try it now!

When you want to design/test your caml query, most of the time uses U2U CAML Query builder. Sometimes you get problem with connection but most of the time, it was working fine for most of the needs.

Recently, I tried CAML Designer which is really nice tool to try as alternative. WPF UI experience with many additional features may impress you to switch to this new tool.

Let me know your experience while evaluating

Thursday, May 17, 2012

PowerGUI script editor: powershell debugging and intellisense

​​​In this post I am going to show you how to use PowerGUI script editor for executing powershell. There are two main advantages of using PowerGUI:
  1. Dubugging of powershell script
  2. Intellisense support
So, let's start setting up PowerGUI to use with sharepoint 2010:
  1. Download and install latest version of PowerGUI.
  2. Download PowerGUI PowerPack for sharepoint.
  3. Start PowerGUI script editor​ and go to File > Powershell Libraries
  4. Click on "Add Module" and add downloaded "PowerPack for sharepoint" library here
  5. That will add another entry "Microsoft.Sharepoint.PowerShell" into the listing. Check the library to make it enable
  6. Restart PowerGUI script editor and you are ready to get started.

Wednesday, May 16, 2012

SP.UI.ModalDialog.showModalDialog not working in chrome

In some version of browser, using will not work due to some reason. I found an alternate method to solve this problem, here is the javascript code:
var dialogSP = null;
if (SP.UI.ModalDialog.showModalDialog) {
    dialogSP = SP.UI.ModalDialog.showModalDialog(options);
} else {
    dialogSP = SP.UI.ModalDialog.commonModalDialogOpen(countryUrl, options, null, {});
}

jQuery.find not working in IE7 for xml data


As part of troubleshooting a shareoint functionality, we found that jQuery.find not working.
We were using jQuery.ajax to call a sharepoint web service and in success function, finding an element in response xml to render it on div.
We fixed this and there are couple of options to fix this that we found from stackoverflow.
1. add dataType: 'xml​' in jQuery.ajax and that will fix it.
2. in response, check for browser is IE7 and variable that is having data is blank, do it with another method, here is javascript code:
if ($.browser.msie && liHtml == "") {
    xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async = false;
    xml.loadXML(response);
    liHtml = $("XmlTagNameToFind",xml).text();
}
I hope this will he you as well.

Creating web application from existing content database

There are situations where you want to propagate one SharePoint web application to some other farm/machine.   I feel the fastest way is to take content database backup and restore it in your destination farm. I have done so in last couple of weeks and I have leaned how to quickly do that.
Here are quick notes from my experience:
Pre-requisites:
I was provided with content database backup and source code. That makes be able to restore site and generate wsps from source code.
Creating  content database from backup:
Go to your database server and do following:
  • Create a blank database that will be used as content database 
  • Restore a database using content database back up from source farm.
Creating a web application:
  • Go to sharepoint central administration and create a new web application
  • While creating a new web application, use existing content database in database section
  • Sometimes if your database is too large, web application creation takes too long and times out. Don't worry at all. web application is still created successfully. It happened to me 4 times out of 5. 
Validating the web application:
  • Go to sharepoint central administration, click on application management. In "Databases" section you will find "Manage content databases"
  • Choose your application and it will show database status and number of site collections. If you are not sure how many site collections are there in backup, anything greater than 0 is good news.
Configure web application to work properly:
we are almost done now. Do following:
  • Go to sharepoint central administration
  • Click on "Application Management"
  • In "Site Collections" section click on "Change site collection administrators"
  • choose your web application set proper data in site admins.
Additional optional steps:
After performing all the above steps, it is still possible that you are not able to access your web application.
  • Last thing to do is to install and deploy wsp by using stsadm or your favorite method. 
Conclusion:
It is always challenging to move applications from one farm to another. Specially when they are depending upon other service applications. In spent last two weeks to learn how to properly do that. I hope this will help you at some point during your sharepoint development.

stsadmin -o deploysolution shows access denied error for some files


Problem

After firing deploysolution, looking at system settings > farm solutions and the error looks something like "Can not overrite xxxx file, access is denied".

Cause

specified file in your error is read only in your web application directory. Most of the time this happens when you are using some source control system that is making the file read only when it is checked in. 

Solution

Go to properties of the file and uncheck read only. If you are running a farm and you got multiple application servers, you need to repeate this for each application server.

Conclusion

80% of the developers uses command line to deploy their wsp as it is the convinient way to add or upgraded the solution.

Finally...

Got the same error? Don't worry try above solution. Didn't worked? Let me know which one worked for you?

Monday, May 14, 2012

using HttpContext.GetGlobalResourceObject in webpart development


I found interesting issue during working with global resource files this week.

Problem:
Event if we are using HttpContext.GetGlobalResourceObject, web part was rendering data in English even if site language is other than English!

If we switch to edit mode, it was working sometime, but most of the time it was showing English text.

Root cause:
We tried creating a new application page and placed a webpart there, it was strange that it was working properly in the application page.

We finally found that at the time of reading resources through  HttpContext.GetGlobalResourceObject web part was not aware of the current UICulture

Solution:
Before:
   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key");
After:​
   1:  var strLinkText = HttpContext.GetGlobalResourceObject("file", "key",SPContext.Current.Web.UICulture);

Conclusion
Finally after passing third argument from SPContext.Current.Web.UICulture it worked properly
​