Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Monday, March 12, 2012

The server returned a non-specific error when trying to get data from the data source

The server returned a non-specific error when trying to get data from the data source. Error in SPD when try to se the Data source of a SP list.
After long search i understood that the calculated field i have added caused this issue.
Initially i added a calculated field Close Date with DateTime data type.
=IF([Statuscolmn]="Closed",[ModifiedColmn],"NA")
or
=IF([Statuscolmn]="Closed",[ModifiedColmn]," ")
or
=IF([Statuscolmn]="Closed",[ModifiedColmn],) This solves the issue but it will insert 12/30/1899 for False condition and not acceptable in reports.

"The server returned a non-specific error..." message was thrown when the dataset returned to the dataview included a row with the calulated field was set to "" or NA. 

To solve this
convert the calculated field type to single line of text. And i changed the  Formula to

=(IF([Status]="Closed",TEXT([Modified],"mm/dd/YYYY"),"NA"))

this solved my issue.

Wednesday, February 29, 2012

Person fields (createdBy, ModifiedBy) field in XSLT

Created By  and Modified fields are shown as rich text in SPD.
If we convert to Text format we can see the html as below

<nobr><span><A HREF="/sites/home/_layouts/userdisp.aspx?ID=100">Rajesh Pillai</A><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'><img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' sip='rajesh.pillai@live.com' id='imn_2225,type=smtp'/></a></span></nobr>

To customize these fields in xslt we need to write some extra steps
1. To get the Email address
<xsl:value-of select= 'substring-before(substring-after(@Author, concat("sip=",$dvt_apos)), $dvt_apos)' disable-output-escaping="no"/>

2. To show only the name
<xsl:variable name="Name" select="substring-before(substring-after(string(@Author),'&quot;&gt;'),'&lt;/A&gt;'"/>

Friday, February 3, 2012

Approaches to integrate ASP.NET web application into SharePoint

Good article here

  • SharePoint Application page approach
  • User control Approach
  • Web part page approach
  • Simple IFRAME approach

Friday, January 27, 2012

SharePoint Calculated field - Compare 3 Date columns

SharePoint Calculated field - Compare 3 Date columns
The logic
if ([Revised Due Date] = "")
set val = [Chartered Due Date]
else if([Chartered Due Date]="")
set val = [Requested Due Date]
else if([Requested Due Date]="")
set val =" NA")
the formulae
=IF(OR([Revised Due Date]<>"",[Chartered Due Date]<>"", [Requested Due Date]<>""), MAX([Revised Due Date],[Chartered Due Date]
,[Requested Due Date]), "NA")

Thursday, January 26, 2012

Getting XML Data From a SharePoint List


  • {0} – The URL to your site.  This could be the root web or a child site.
  • {1} – The GUID for your list. 
  • {2}- The GUID of the view - optional

Thursday, December 29, 2011

To Access SharePoint fields in JQuery

To Access SharePoint fields in JQuery
By default we can access by
$("input[title='title name']") 
or
$("input[VALUE='OK']")    // for OK button

If we modify to  Sharepoint List form field
See the source of the form and find out the ID in SPD.
Example $("#[id*='ff2_1']")     // 2nd  field.

Tuesday, December 27, 2011

SharePoint Infopath Forms Library missing

I have created a new 2010 portal with publishing features template. And tried to create a forms library, ohh gosh!! where is the Form Library under 'Create'. Searched the settings in 'Central Administration', everything seems to be right there.
Got an idea... go to InfoPath Designer and publish a new form template from there to this portal.
Every thing went on smooth except the it has created a simple document library instead forms library.Very Bad.

Ohhh may be i might have missed some thing  let me check the site settings
  • Site Collection Features –> Office SharePoint Server Enterprise Site Collection features
  • Site Features –> Office SharePoint Server Enterprise Site features
No luck dude, still no forms library.

After lot of search & struggling around... found out that
  • Site Features –> Team Collaboration Lists
thats SharePoint!. :)

Wednesday, August 24, 2011

What are the features available in SharePoint 2010 which are not available in MOSS 2007?

1.      New User Interface including Ribbon
2.      Sandboxed Solutions
Also called as User Solutions, is a new concept which allows site collection administrators to deploy solutions at the site collection level which is safe to run and not affect the other site collections and web applications running on the same farm. Farm administrators can monitor sandboxed solutions and place restrictions on the resources, such as memory and CPU cycles, they can use. Sandboxed Solutions does not cover full SharePoint object model but it addresses the key scenarios like custom web parts and event receivers. The solution deployment as in SharePoint 2007 is still exists in SharePoint 2010 but those solutions are called as Farm solutions.
3.      SharePoint Workspace
Microsoft Office Groove has been renamed to SharePoint Workspace in SharePoint 2010. SharePoint Workspace provides local and offline read-write access to SharePoint lists and libraries and also incorporates offline-online synchronizations.
4.      Stsadm command-line tool is superseded by Windows PowerShell 2.0
5.      BCS(Business Connectivity Services) 
Provides Read-Write capable connectivity from Client and Server to Database, WCF/Web Services and .Net Sources.
6.      Client Object Model
The SharePoint 2010 Client Object Model is a very cool feature of SharePoint 2010 Foundation Server that enables developers to write applications that access SharePoint data from a .NET application running on a client computer, from a Silverlight application, and from JavaScript running client-side in a SharePoint web part.  The client object model enables this without requiring the developer to write or install code on the SharePoint server. (Using Microsoft.SharePoint.Client namespace)
7.      Visual Web parts
8.      Redesigned Central Administration web site
9.      Shared Service Provider (SSP) no more exists
SSP's have been replaced by Service Applications in SharePoint 2010. Earlier in SharePoint 2007, all services were combined into a SSP. Now in SharePoint 2010, all services are running as independent Service Application.
10.  Built-in Silverlight Support         
11.  Rich and Improved Theming Support
The new 2010 themes use an entirely different design. SharePoint 2007 themes used CSS and images while the new 2010 themes use the .thmx format. This means themes can be easily created using PowerPoint or any other tools(ex Microsoft Theme Builder)
12.  Multiple Browser Support  - IE, Firefox & Safari
13.  Rich Media support and Digital Asset Management
SharePoint 2010 includes a Media web part built using Silverlight, Video content type, Audio content type, and Image content type. 

Tuesday, April 19, 2011

Sand boxed development in Visual studio 2010


After my initial search, i thought it's good to remember few things about sandbox solutions
The facts about Sand boxed development 

A new feature in SharePoint 2010, called sandboxed solutions, helps enabling farm administrators to feel comfortable that the SharePoint farm is safe, giving site collection administrators the authority to manage the applications in their site collection, and providing developers with the flexibility to create solutions they know will be deployed in a safe and rapid manner.

The structure of a sandboxed solution is very similar to a farm solution, which generally runs with full-trust permissions. The main differences lie in how a sandboxed solution is deployed and in the process that hosts the solution (which determines whether a solution is a sandboxed solution or a farm solution). This means that the same sandboxed solution can run with full trust when it’s deployed at the farm level and with partial trust when it’s deployed at the site collection level.
A SharePoint solution is a deployable package that can contain features and assemblies. The solution package is a .cab-based file with a .wsp extension. Visual Studio 2010 SharePoint project templates create .wsp package files. A solution might contain a number of SharePoint features, and these features provide functionality such as Web Parts, list definitions, modules, and event receivers.

When we open .package file in a sandboxed solution in Microsoft Visual Studio 2010 it shows that the global assembly cache is the deployment target of assemblies. But actually it is not stored in GAC or in file system.

 Actually, the sandbox process prevents accessing data outside the site collection where the solution has been deployed. This means, the following operations are not allowed in a sandbox framework 
• We can’t access the Internet to make Web service calls.
• We can’t access a hard drive to read or write files.
• We can’t access code that is not marked to allow partially trusted callers.
• We can’t deploy files to disk or add assemblies to the GAC in a sandboxed solution.
• We can't do any security-related functionality, such as running RunWithElevatedPriviledges and other SPSecurity methods, is not allowed.
• We cannot deploy a visual web part using sandbox framework.
The assemblies in a sandboxed solution are included in the solution package (.wsp file), and the package is deployed to the site collection's Solutions Gallery. [Site Actions /Site Settings/ Galleries section/Solutions]. When a sandboxed solution is accessed for the first time, such as when a user navigates to a page that contains a Web Part from a sandboxed solution, any assemblies in the solution are extracted from the package in the gallery and copied to the file system of the server that is handling the sandboxed request. The default location is C:\ProgramData\Microsoft\SharePoint\UCCache; however, this is configurable on each server that is running the User Code Host Service, which is called the Microsoft SharePoint Foundation Sandboxed Code Service in the user interface of the Central Administration application. The executable of this service is SPUCHostService.exe. The server that handles the sandboxed request is not necessarily the front-end web server that is handling the initial HTTP request: The Microsoft SharePoint Foundation Sandboxed Code Service can be run on back-end application servers in the farm instead. Because the sandboxed user process (SPUCWorkerProcess.exe) cannot copy anything to the file system, the copying is done by the Microsoft SharePoint Foundation Sandboxed Code Service.
The assemblies of a sandboxed solution do not stay in the file cache perpetually. When the user session that accessed the solution ends, the assemblies stay in the cache for only a short time, and they may be reloaded from there if another user session accesses them. Eventually, if they are not accessed, they are removed in accordance with a proprietary algorithm that takes into account how busy the server is and how much time has gone by since the assemblies were last accessed. If the sandboxed solution is used after that time, the assemblies are extracted again and copied to the UCCache.

Debugging

We all know how to debug in full-trust solutions, which run under the IIS worker process used by SharePoint called w3wp.exe. Surprisingly, Sandboxed solutions do not run under this process. They run under the sandboxed worker process called SPUCWorkerProcess.exe, VS2010 automatically attaches the debugger to this process when we press F5. If a solution that’s already deployed we need to attach to this process manually.

MS Best practices says
  • Avoid Creating Static Members 
  • Avoid Throwing Unhandled Exceptions 
  • Use Both the AllowPartiallyTrustedCallers Attribute and the SharePointPermission Attribute
What can be implemented in sandboxed solution?
Assembly
content types
event receivers
Feature
Feature receivers
Web parts
Field
Read more..

Things not allowed in sanboxed development
 - Read..

Tuesday, April 12, 2011

Using Disposable Windows SharePoint Services Objects

Using Disposable Windows SharePoint Services Objects
We can employ certain coding techniques to ensure object disposal. These techniques include using the following in your code:
  • Dispose method
  • using clause
  • try, catch, and finally blocks 
Dispose vs. Close Method Usage
The Dispose and Close methods for the SPWeb object and SPSite object function in the same way. The Dispose method calls the object's Close method. MS recommends calling the Dispose method, instead of Close, because SPWeb and SPSite objects implement the IDisposable interface, and standard .NET Framework garbage collection calls the Dispose method to free any resources associated with the object from memory.
You can automatically dispose of SharePoint objects that implement the IDisposable interface by using the Microsoft Visual C# using statement.

String str;
using(SPSite oSPsite = new SPSite(http://server/))
{
   using(SPWeb oSPWeb = oSPSite.OpenWeb())

    {
      str = oSPWeb.Title; 
      str = oSPWeb.Url;
     }
}

void OpenWebNoLeak()

 { 
String str;
using (SPSite siteCollection = new SPSite(http://moss/))
{
   using (SPWeb web = siteCollection.OpenWeb())
  {
     str = web.Title;
    str = web.Url;
  } // SPWeb object web.Dispose() automatically called.
} // SPSite object siteCollection.Dispose() automatically called.
}

Bad coding practices 
Ex1 
// Do not do this. Dispose() is automatically called on SPWeb.
using( SPWeb web = SPControl.GetContextWeb(HttpContext.Current)) { ... }

 Ex2 
using (SPWeb web = new SPSite(SPContext.Current.Web.Url).OpenWeb())
{
// ... New SPSite will be leaked.
} // SPWeb object web.Dispose() automatically called.
Ex3 
void SPControlBADPractice()
{
   SPSite siteCollection = SPControl.GetContextSite(Context);
   siteCollection.Dispose(); // DO NOT DO THIS
   SPWeb web = SPControl.GetContextWeb(Context);
   web.Dispose(); // DO NOT DO THIS.
}

 Good practices 
Thumb rule
If you create the object with a new operator, ensure that the creating application disposes of it.
Ex1 
void CombiningCallsBestPractice()
{

  using (SPSite siteCollection = new SPSite(SPContext.Current.Web.Url))
 {
   using (SPWeb web = siteCollection.OpenWeb()) 
   {
    //Perform operations on site.
   } // SPWeb object web.Dispose() automatically called.
} // SPSite object siteCollection.Dispose() automatically called.
}

If we are not performing any operations on the SPSite object, we could write this more succinctly, as in the following code example. 
void CombiningCallsBestPractice()
{
 using (SPSite siteCollection = new SPSite(SPContext.Current.Web.Url)) 
   using (SPWeb web = siteCollection.OpenWeb())
    {
      //Perform operations on site.
    } // SPWeb object web.Dispose() automatically called; SPSite object
      // siteCollection.Dispose() automatically called.
}

Ex2 
Try and finally blocks or a using statement would be required to avoid potential leaks when you create a disposable object within a foreach block,
public static void SPSiteCollectionForEachBestPractice()
{
string sUrl = http://rajtestsite/
using (SPSite siteCollectionOuter = new SPSite(sUrl))
{ 
   SPWebApplication webApp = siteCollectionOuter.WebApplication;
   SPSiteCollection siteCollections = webApp.Sites;
   SPSite siteCollectionInner = null;
   foreach (siteCollectionInner in siteCollections)
   {
     try //Should be first statement after foreach.
     { 
        Console.WriteLine(siteCollectionInner.Url);
         //Exception occurs here.
      }
      finally
     {
        if(siteCollectionInner != null)
        siteCollectionInner.Dispose();
     }
  }
}
} // SPSite object siteCollectionOuter.Dispose() automatically called.
}
Ex 3
void SPControlBestPractice()
{
  SPSite siteCollection = SPControl.GetContextSite(Context);
  SPWeb web = SPControl.GetContextWeb(Context);
// Do NOT call Dispose().
}
Ex4 
void SPSiteCollectionAddNoLeak()
{
   SPWebApplication webApp = new SPSite("http://moss").WebApplication;
   SPSiteCollection siteCollections = webApp.Sites;
   using (SPSite siteCollection = siteCollections.Add("sites/myNewSiteCollection", "DOMAIN\\User",
   rajan@ms.com))
   {
    } // SPSite object siteCollection.Dispose() automatically called.
}

Same for webcollection.Add methods too.
Ex4
 SPSite.RootWeb Property & SPWeb.ParentWeb Property

It is no longer advisable to call the Dispose method on the SPSite.RootWeb property whenever any of these properties are used.
 public void RootWebBestPractice() 
{// New SPSite.
using (SPSite siteCollection = new SPSite(http://moss/))
{
   SPWeb rootWeb1 = siteCollection.RootWeb;
// No explicit rootWeb1 dispose required.
} // siteCollection automatically disposed by implementing using().
// rootWeb1 will be Disposed by SPSite.
// SPContext and SPControl
SPWeb rootWeb2 = SPContext.Current.Site.RootWeb;
// Also would apply to SPControl.GetContextSite(Context); 
// No explicit rootWeb2 dispose required because it's obtained from SPContext.Current.Site.
}
It is no longer advisable to call the Dispose method on SPWeb.ParentWeb property whenever any of these properties are used.
using (SPSite site = new SPSite(http://localhost/))
{
using (SPWeb web = site.OpenWeb())
{
   SPList list = web.Lists["Announcements"]; 
   SPWeb parentWeb = list.ParentWeb; //No explicit dispose required.
}
}
Ex 5
SPWeb.Webs Property
The SPWeb.Webs property returns an SPWebCollection object. The SPWeb objects in this collection must be disposed.
void WebsNoLeak()
{
using (SPSite siteCollection = new SPSite(http://moss/))
{

   using (SPWeb outerWeb = siteCollection.OpenWeb()) 
    {
       foreach (SPWeb innerWeb in outerWeb.Webs)


        {   try //Should be first statement after foreach. 
              {   // ...}
            finally 
              {
                 if(innerWeb != null)
                 innerWeb.Dispose();
               }
          }

 } // SPWeb object outerWeb.Dispose() automatically called. 
} // SPSite object siteCollection.Dispose() automatically called.
}

 Cross Method Dispose Patterns

 The following example demonstrates the common practice of holding onto the SPSite and SPWeb objects across methods in a class. Sometimes this design pattern is required, but ensure that you do not overlook the appropriate time to call Dispose when you are finished with the cross method calls. The following code example shows a pattern where SPSite and SPWeb leak when the class goes out of scope.

public class CrossMethodLeak
{
private SPSite _siteCollection = null;
private SPWeb _web = null;
public void MethodA()
{
   _siteCollection = new SPSite(http://moss/);
   _web = _siteCollection.OpenWeb();
}

  public void MethodB() 
{
   if (_web != null)
   {
    string title = _web.Title;
   }
}

public void MethodC()

 {
   if (_web != null)
    {

      string name = _web.Name; 
    }
 }
}

Conclusion 
Because many SharePoint objects implement the IDisposable interface, you must take care when using these objects to avoid retaining them in memory. You can read the completed article here

SharePoint Dispose Checker Tool

SPDisposeCheck is a tool that helps developers and administrators check custom SharePoint solutions that use the SharePoint Object Model helping measure against known Microsoft dispose best practices. This tool may not show all memory leaks in your code and may produce false positives which need further review by subject matter experts.

12/13/2010 update: SPDisposeCheck v14.0.4762.1000
SPDisposeCheck tool can be downloaded
http://archive.msdn.microsoft.com/SPDisposeCheck

Wednesday, March 23, 2011

WebTrends Reports in SharePoint 2010

Custom WebTrends Reports in SharePoint 2010 master page.

1.Page visits
2.Document visits
3.Authenticated user visits

Thursday, March 17, 2011

JQuery to find SharePoint Logged in User

Upload "jquery-1.3.2.min.js" & from code plex - "SPServices 0.6.0.js"

Add below lines in Javascript Tag & using $().SPServices.SPGetCurrentUser()

var thisUserAccount = $().SPServices.SPGetCurrentUser({
fieldName: "Name",
debug: false
});

var thisUserName = $().SPServices.SPGetCurrentUser({
fieldName: "Title",
debug: false
});

Tuesday, February 1, 2011

Solution Deployment with SharePoint 2007

Solution packages are the preferred mechanism for deploying WSS components. The solution package itself is a compressed CAB file with a .wsp extension, and it contains one or more WSS components along with any dependent files that need to be deployed on each front-end Web server.
Read more...

Wednesday, October 6, 2010

Few New Features in SharePoint 2010

1. Enhanced SharePoint Designer— Microsoft SharePoint Designer 2010 sports a new UI, improved workflow, and improved integration between designers. Also has a tabbed interface and provides breadcrumb navigation.
2. New browser support—SharePoint 2010 supports an extended set of browsers. It's designed to support XHTML 1.0–compliant browsers and will support Internet Explorer (IE) 8.0 and IE 7.0, Firefox, and Safari. Notably, IE 6.0 isn't supported. So far, there's been no official mention of Google Chrome or Opera.
3. Enhanced collaboration features -calendars from Microsoft Exchange Server can be merged with SharePoint calendars.There's a new group authentication feature that's based on distribution list or organization and a new rich text editor for creating wikis.
4.Visio Services -share and collaborate on Visio diagrams.(Users no need to have Visio installed)
5.Usage reporting and logging - It has a new database to support usage reporting & logging.
6.FAST Search -enhanced capabilities like content-processing pipeline, metadata extraction, visual search, and advanced linguistics.
7.SharePoint Best Practices Analyzer -Microsoft's guidance for SharePoint implementation and troubleshooting.
8.New hardware requirements— SharePoint 2010 will ship only as a 64-bit product.
9. New software requirements—In addition to new hardware requirements, SharePoint 2010 will require an x64 edition of either Windows Server 2008
or Server 2008 R2. It also requires a 64-bit version of Microsoft SQL Server 2008 or SQL Server 2005.
10.New SharePoint editions -In an effort to better unify the SharePoint lineup, Microsoft will make some big changes to the SharePoint editions with the 2010 release. Windows SharePoint Server (WSS) is gone, and so is Microsoft Office SharePoint Server (MOSS). The free WSS has been replaced by the new SharePoint Foundation 2010. MOSS is replaced by SharePoint Server 2010, which will be available in either the Standard or Enterprise edition as well as in editions for strictly internal sites and for Internet or extranet sites.

Tuesday, August 31, 2010

Monday, August 30, 2010

To get a ID(GUID) of a SharePoint List

•Delete everying before and including “List=”.
•Change “%7B” to “{”
•Change all “%2D” to “-“
•Chnage “%7D” to “}”