All About SharePoint

Liedong(Ken) Zheng,SharePoint Leader at SIMPLOT

SharePoint 2007 Backup Failed – Cannot open backup device

Posted by ken zheng on January 3, 2012

You may have seen this error Error: Object SharePoint_Config failed in event OnBackup. For more information, see the error log located in the backup directory. SqlException: Cannot open backup device ‘\\servername\backup\spbr0001000001.bak’. Operating system error 5(error not found).

NB: Use UNC Path ”\\172.16.5.138\c$\Temp”

Here are the steps You need to check

  • Set the SQL Server (MSSQLSERVER) Windows service to run as a domain account. Will require a restart of the service and IIS.
  • Setup sharing on the backup folder. Grant access for the identity that the Central Administration Application Pool runs under, the database SQL account, the identity that the Timer service runs under, to change and read rights.
  • On each of the SharePoint servers check you can access the share.
  • On each of the database servers check you can access the share.
  • Set the folder security, grant privledges for the identity that the Central Administration Application Pool runs under, the database SQL account, the identity that the Timer service runs under to all rights apart from Full Control.

Posted in Sharepoint, SQL | Tagged: | Leave a Comment »

String Array Initialization

Posted by ken zheng on December 22, 2011

This is quite common if you want to initialize the values in array. But it is not recommend if doing String[100], it creates 100 reference to a String Class. Not an instance of String Class. So, in case you only use 50 then other half will not be loaded into memory.

You can use

if (strArr[i] == null)
System.out.println("empty")
else
System.out.println(strArr[i])

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

or

public static void Populate<T>(this T[] arr, T value ){
  for ( int i = 0; i < arr.Length;i++ ) {
    arr[i] = value;
  }
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Posted in .Net | Tagged: , | Leave a Comment »

Use CrossListQueryCache has Better performance than SPSiteDataQuery

Posted by ken zheng on December 14, 2011

I use SPSiteDataQuery to query around thousands lists  and ten thousands items. when running at web part, it keeps throwing time out. And interesting is the SPSiteDataQuery doesn’t use the indexed columns.

So I use CrossListQueryCache instead.

Below is an example of a query that queries all the Publishing pages libraries that resides in the current SPWeb and all childWebs.

private DataTable ExampleQuery()

        {

            clqi = new CrossListQueryInfo();



            // Insert the list types that you want to use. In this case, its the publishing page library (850, see code below)

            clqi.Lists = "<Lists ServerTemplate=\"" + (int)ListServerTemplateCodes.PageLibrary + "\" />";



            // Insert the fields that you want to see. If there is a field inside that doesnt exist in the list that you query, your result will be nill, nada, nothing.

            // Make sure that you put in the INTERNAL field names!

            clqi.ViewFields = "<FieldRef Name=\"Title\" /><FieldRef Name=\"FileLeafRef\" /><FieldRef Name=\"Nieuws_x0020_Type\" /><FieldRef Name=\"Nieuws_x0020_Leverancier\" /><FieldRef Name=\"Uitgelicht\" /><FieldRef Name=\"Created\" /><FieldRef Name=\"Comments\" />";



            // scop to use. Another possibility is SiteCollection

            clqi.Webs = "<Webs Scope=\"Recursive\" />";



            // turn the cache on

            clqi.UseCache = true;



            // if row limit == 0, you will get 0 results

            clqi.RowLimit = 100;



            // I know a stringbuilder would be better, but i wanted to show the markup of the query

            clqi.Query = "<OrderBy>" +

                            "<FieldRef Name='Title' />" +

                        "</OrderBy>" +

                        "<Where>" +

                            "<Or>" +

                                "<Eq>" +

                                    "<FieldRef Name='ContentType' />" +

                                    "<Value Type='Text'>News Item</Value>" +

                                "</Eq>" +

                                "<Eq>" +

                                    "<FieldRef Name='ContentType' />" +

                                    "<Value Type='Text'>LocationNews Item</Value>" +

                                "</Eq>" +

                            "</Or>" +

                        "</Where>";



            // put the CrossListQueryInfo object into the CrossListQueryCache

            CrossListQueryCache clqc = new CrossListQueryCache(clqi);



            // and query the data!

            // make sure: the GetSiteData(SPWeb web) and GetSiteData(SPWeb web, SPSiteDataQuery query) DO NOT use caching!!!

            DataTable tbl = clqc.GetSiteData((SPContext.Current.Site, CrossListQueryCache.ContextUrl());



            // return the datatable

            return tbl;

        }

The enum below can be used to make life a little bit easier. I got it from:http://www.aspenhorizons.com/devblog/?p=29

public enum ListServerTemplateCodes
    {

        GenericList = 100,

        DocumentLibrary = 101,

        Survey = 102,

        LinksList = 103,

        AnnouncementsList = 104,

        ContactsList = 105,

        EventsList = 106,

        TasksList = 107,

        DiscussionBoard = 108,

        PictureLibrary = 109,

        DataSources = 110,

        SiteTemplateGallery = 111,

        UserInformationList = 112,

        WebPartGallery = 113,

        ListTemplateGallery = 114,

        XMLFormLibrary = 115,

        MasterPagesGallery = 116,

        NoCodeWorkflows = 117,

        CustomWorkflowProcess = 118,

        WikiPageLibrary = 119,

        CustomGridForAList = 120,

        DataConnectionLibrary = 130,

        WorkflowHistory = 140,

        GanttTasksList = 150,

        MeetingSeriesList = 200,

        MeetingAgendaList = 201,

        MeetingAttendeesList = 202,

        MeetingDecisionsList = 204,

        MeetingObjectivesList = 207,

        MeetingTextBox = 210,

        MeetingThingsToBringList = 211,

        MeetingWorkspacePagesList = 212,

        PortalSitesList = 300,

        BlogPostsList = 301,

        BlogCommentsList = 302,

        BlogCategoriesList = 303,

        PageLibrary = 850,

        IssueTracking = 1100,

        AdministratorTasksList = 1200,

        PersonalDocumentLibrary = 2002,

        PrivateDocumentLibrary = 2003

    }

Posted in Sharepoint | Tagged: , | Leave a Comment »

Find Users who Did Anonymous Surveys in SharePoint

Posted by ken zheng on December 14, 2011

I had an interesting request to find out who has done the Anonymous Surveys in SharePoint. you cannot see the name from the SharePoint interface but you can directly query your SharePoint content database:

SELECT AllUserData.*, UserInfo.tp_Title
FROM AllUserData LEFT JOIN
   UserInfo ON UserInfo.tp_id = tp_author
WHERE AllUserData.tp_listid = '00000000-0000-0000-0000-000000000000'
  AND UserInfo.tp_siteid = '11111111-1111-1111-1111-111111111111'

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Where the 0000s and 1111s above are your actual survey list guid and site collection guid.

To find List GUID is easy, just go to list setting and click “Audience targeting settins”, the GUID will be at the end of the URL.

To find site collection guid, you will need go to your content database and open the “Sites” table. Also if you are interested on subsite ID you can search on web table

Posted in Sharepoint | Tagged: , | 1 Comment »

SPSiteDataQuery – The query cannot be completed because the number of lists in the query exceeded the allowable limit

Posted by ken zheng on December 5, 2011

The query cannot be completed because the number of lists in the query exceeded the allowable limit. For better results, limit the scope of the query to the current site or list or use a custom column index to help reduce the number of lists

I have hit this error when using the SPSiteDataQuery, the trick is to

my SPSiteDataQuery had used MaxListsLimit where MaxListLimit should have been for the Lists property of my SPSiteDataQueryI was using

"<Lists BaseType=’1′ MaxListsLimit=’0′/>"

When what I needed was just:

"<Lists BaseType=’1′ MaxListLimit=’0′/>"

Posted in Sharepoint | Tagged: | Leave a Comment »

Error HRESULT E_FAIL has been returned from a call to a COM component.

Posted by ken zheng on November 29, 2011

I got this error when start a full crawl in 2010 server.

Work Arround :

Open the web.config for the website 80. Find the line : identity impersonate="true"

If the identity impersonate is set to "false" (which create the error during the crawl), set up to "true".

Then run the crawl again. It completes now sucessfully.

 

NB: If you have more than one WFE, make sure you updated the all servers

Posted in Sharepoint | Tagged: | Leave a Comment »

Document Information Panel: Value’ is in nil content, Metadata won’t apply to one library item, remove the Document Properties with the Document Inspector

Posted by ken zheng on November 25, 2011

Sometime when a metadata type changed, the DIP will do funny things.

Solution: remove the Document Properties with the Document Inspector

Probably, the Word document you are trying to upload is a Word document downloaded from another SharePoint document library. The source, originaldocument library has probably other metadata (columns) than the document library to which you are trying to upload the Word document.

To fix this, remove these hidden metadata with the Document Inspector:

  1. Open the Word 2007 document and click the Office 2007 button, located on the top-left of the window.
  2. Choose Prepare –> Inspect Document, which will start the Document Inspector.
  3. Check the box Document Properties and Personal Information, which will inspect hidden metadata saved with the document.
    image
  4. Choose Inspect.
  5. Choose Remove All. This will remove all Document server properties and Content type information saved with the Word document.
    image

Aferwards, you’ll be able to upload the Word document to your own SharePoint document libary.

Posted in Sharepoint | Tagged: | Leave a Comment »

Default Column Values in SharePoint 2010 Missing from Document Information Panel

Posted by ken zheng on November 23, 2011

If you developed a word template in a content type, later on by setting the default values. You will find the default values are not shown in the Document Information panel.

After doing some testing I figured out that the Document Information Panel seems to get out of sync with a content type when changes are made to the content type schema (including its underlying fields, one of which I changed to set a default value). A lot of the information I found on the web says this only happens with custom (InfoPath-based) Document Information Panel forms or with custom document templates, but it appears to happen in pretty much all cases, not just custom DIP forms or custom document templates.

The fix: You need to “refresh” the DIP form associated with your content type. One way to do this is using InfoPath as Microsoft suggests here: http://msdn.microsoft.com/en-us/library/ms494347.aspx.

But I still can’t get the default value even it shown in the InfoPath template. the workaround I am using is to modify the word template, just open a new document from the library and select the default value from the Information Panel then saved it as word template. Upload to your content type. It works!

Posted in Sharepoint | Tagged: | Leave a Comment »

401: “You do not have permission to view this directory or page.”

Posted by ken zheng on November 23, 2011

Most time the error indicates the app pool identity account in IIS may not have permission.

Posted in Tools | Tagged: | Leave a Comment »

SharePoint 2010 InfoPath Attachments Only Have Download No Open Option

Posted by ken zheng on November 21, 2011

I have users report that InfoPath Attachments must be saved and open. There is no open option.

clip_image001

After a few search, and it actually SharePoint 2010 block the file.

SharePoint 2010 utilizes this enhanced security feature in IE 8 to block the opening of file types it considers vulnerable to scripting or other attacks, such as PDFs.   You can modify SharePoint’s behaviour by changing the Browser File Handling option in the Web Application General Settings of SharePoint 2010.   Your options are permissive and strict, with strict being the default.

image

Posted in InfoPath, Sharepoint | Tagged: | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.