There has been an error while loading the form

Leave a comment

Have you ever tried just simply clicking on an item in a list and get the following error?

“There has been an error while loading the form because the fields in the form and SharePoint list do not match.”

LoadFormError

As you can see in the error message above that the ‘Approver’ field is the root cause of this error.

In my previous post when I was getting the workflow error on this list (I’ll call it List A), I changed this column for allowing multiple values from ‘yes’ to ‘no’.  Now, I can’t even open an existing item from List A.

The same settings were also made on a different list (I’ll call it List B) on the same site, and List B continues to work.

After much head scratching, I started comparing form settings of both lists.  List A has two options for loading forms.

FormDefaultOptions

While List B has only one option.

FormOptions

Both lists use out-of-box SharePoint list form, after selecting ‘Use the default SharePoint form’, I was able to open list items on List A again.

Learn more about Centric’s Portals and Collaboration Practice

 

Advertisements

Automating Site Directory in SharePoint 2013

Leave a comment

A while ago I posted on how to display Sites or Site Collections using Content Search Web Part here.

Well, since CSWP periodically displays “Sorry, something went wrong”, users were not happy with this solution.

So, I wrote a PowerShell script to update a list called “Site Directory”, and placed it on the home page.  I then added one additional logic to get new site collections created from the previous day.  After adding the script to Task Scheduler, I didn’t have to worry about missing newly created site collections.

To get all of the site collections created from the previous day, I used:


$Today = [DateTime]::Today
$Yesterday = $Today.AddDays(-1)

$siteCollections = Get-SPWebApplication http://demosite.vee.local | Get-SPSite -limit ALL | where {$_.RootWeb.Created -ge $Yesterday}

Now keep in mind, $Today will return today’s date at midnight and the same goes for $Yesterday (yesterday’s date at midnight).  I pointed this out to make sure that when you schedule this script in the Task Scheduler, you set it to run accordingly.  And, of course, replace the Web application with your Web application.

Writing it to a list was pretty straightforward, I added a category to the list, so I would have an additional option to display different views on the page.

In this list (Site Directory), there’s a hyperlink column.  I wanted the users to click on the hyperlink using a display name instead of the URL.  So, the $hyperlink in the script, will display the “friendly name”(ex: Coffee Beans) instead of the URL (ex: http://demosite.vee.local/dept/coffee%20beans).


foreach($siteCollection in $siteCollections)
{
  $web=$siteCollection.Rootweb;

  $web.Title + "," + $siteCollection.Url + "," + $web.Created | Out-File -Encoding Default -Append -FilePath $outFile;

  $siteCollection.Dispose()
};

$newItem = @{}
$sites = Import-Csv -path $outFile

$web = Get-SPWeb "http://demosite.vee.local";
$list = $web.GetList("http://demosite.vee.local/lists/Site Directory");

foreach($site in $sites)
{
  $siteURL =  $site.URL

  if($siteURL -match "/apps/")
  {
    $category = "APPS"
  }
  elseif($siteURL -match "/dept/")
  {
    $category = "DEPT"
  }
  else
  {
    $category = "DEFAULT"
  }
    $newItem = $list.items.Add();
    $newItem["Title"] = $site.'Title'
    $hyperlink = $site.URL + ", " + $site.Title
    $newItem["SiteURL2"] = $hyperlink
    $newItem["Category"] = $category

  #$newItem.Update();
  $web.Dispose();
};

Well, since I made this change, the users are happy.  No complaints! 🙂

 

CSWP: Display Template Listing Sites/Site Collections

1 Comment

One of the clients I’m working with wanted to list all of their site collections and place a “directory” on a single page with some groupings (based on managed paths).

The easiest way I could think of was to use Content Search Web Parts (CSWPs).

I used the following query:

QueryBuilderSiteCollection

My search result looked like this.

SiteCollectionPreview2

Note: You can change the query to display all sites within a site collection by using STS_Web instead of STS_Site.

The OOTB list of sortable items of the Query Builder didn’t have an option for me to sort the site title alphabetically.  So, I made a change to the SiteTitle in Search Scope (Managed Properties) to include sortable.  And I waited until Search finished crawling/indexing the modified setting.

After Search finished indexing, I was able to select the the setting I needed to sort the sites by their titles.

I selected the Two Lines Display Template.  However, the OOTB display was not exactly what the client was looking for.

TwoLineDT2

So I started modifying the display template to get rid of the icon/image displayed in front of each link and the spacing between the links.

I renamed my Display Template to “Item_NoImageOneLine.html”, changed the Title to “No Image One Line”, added a style tag, and commented out the image section.

<div class="cbs-Item" id="_#= containerId =#_" data-displaytemplate="Item1Line" style="padding-bottom:5px">
<!--<a class="cbs-ItemLink" title="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= pictureLinkId =#_">
<img class="cbs-Thumbnail" src="_#= $urlHtmlEncode(iconURL) =#_" alt="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= pictureId =#_" />
</a>-->
<div class="cbs-Detail" id="_#= dataContainerId =#_">
<a class="cbs-Line1Link ms-noWrap ms-displayBlock" href="_#= linkURL =#_" title="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= line1LinkId =#_">_#= line1 =#_</a>
<!--#_

Here’s the final result.

TwoLineDTFinal

Learn more about Centric’s Portals and Collaboration Practice

Add E-mail to People Search Display Template

2 Comments

This is a follow up to my previous post on adding phone extension to people results page (PeopleResults.aspx).

This post provides steps on how I added e-mail with action (mailto) to people search.

WorkEmail is one of the default user profile properties already mapped in SharePoint both in User Profile Property and in Search Schema. This makes my job a bit easier because all I have to do is modify my Display Template to include this value.  Some of the steps listed here are the same as my previous post.  I hope this makes things easier than flipping back and forth between the two.

  1. If you already have a custom display template for Item_Person, skip to step 6.  If this is the first time you need to edit the display template for people results, continue to the next step.
  2. From Search Center, select the following:
    • Site Settings
    • Master pages and page layouts
    • Display templates
    • Search
  3. Download ‘Item_Person.html’, save it on your local drive with a different name (ex: My_Item_Person.html)
  4. Modify Title. This will be used later when I modify the People Search Core Results Web Part.
  5. <title>My People Item</title>
  6. In <div id=”ContactInfo”>tag, add
<!--#_ 
                                        if(has_email == true) {
_#-->
                                            <div id="WorkEmailField">
<!--#_ 
                                                var encodedWorkEmail = $htmlEncode(ctx.CurrentItem.WorkEmail);
                                                var displayWorkEmail = Srch.U.getSingleHHXMLNodeValue(hhProps, "workemail");
                                                if ($isEmptyString(displayWorkEmail)) { displayWorkEmail = encodedWorkEmail }
_#--> 
                                                <div id="WorkEmailValue" class="ms-srch-ellipsis" title="_#= encodedWorkEmail =#_"><a href="mailto:_#= encodedWorkEmail =#_"> _#= displayWorkEmail =#_ </a></div>
                                            </div>
<!--#_ 
                                        }
_#-->

7.  Save My_Item_Person.html, upload it to the Display Template/Search gallery, and publish it

8.  From Search Center, type in a query term (ex: Executive)

9.  From ‘Site Settings’, select ‘Edit Page’

10.  Edit ‘People Search Core Results’ Web Part

11.  Expand ‘Display Templates’, select ‘Use a single template to display items’, select My People Item, then select ‘OK’

12.  Check In and Publish the People Results page (PeopleResults.aspx)

Your results page shoud look similar to the following.  Note that the OOTB results page only displays Name, Title, and Department

PeopleResults

Again, these steps may not be the greatest, but they worked for me.

Add Phone Extension to Display Template for People Search

Leave a comment

One of the clients I worked with store users’ phone extension in a string (Multi value) field in their Active Directory, though this value could be stored in a regular string field. Regardless of where the value is stored, my objective was to display this value in people search (PeopleResults.aspx). Steps I used below may not be the greatest, but they worked for me.

  1. Map a SharePoint user profile property to this AD attribute. I used ‘PhoneExtension’ for this one.
  2. Start Full Profile Synchronization
  3. Start Full or Incremental Crawl in Search
  4. From Search Service Application, select ‘Search Schema’
  5. Select ‘Crawled Properties’ and search for ‘PhoneExtension’. I did this step to verify that the property I created was crawled, and to allow me to move to the next step. You should see ‘People:PhoneExtension’ for your search.
  6. Select ‘Managed Properties’, then select ‘New Managed Property’. I created ‘PhoneExtension’ as a ‘Text’ type, and selected the following:
    • Queryable
    • Retrievable
    • Safe
  7. Select ‘Add a Mapping’, type ‘PhoneExtension’ in the ‘Crawled property selection’ window
  8. Select ‘People:PhoneExtension’, then click ‘OK’ to close the ‘Crawled propety selection’ window
  9. Click ‘OK’ again to close the ‘New Managed Property’ window
  10. Start Full Crawl, wait for this to complete
  11. From Search Center, select the following:
    • Site Settings
    • Master pages and page layouts
    • Display Templates
    • Search
  12. Download ‘Item_Person.html’, save it on your local drive with a different name (ex: <Client>_Item_Person.html)
  13. Modify title. This will be used later when I modify the People Search Core Results Web Part.
<title>Client People Item</title>

14.  Add ‘PhoneExtension’:’PhoneExtension’ to the end of the mso:ManagedPropertyMapping line (about line 13 or so).  Since ‘WorkPhone’ is already mapped in SharePoint as one of the default user property mappings, I added it here as well.

ManagedPropertyMapping

<mso:ManagedPropertyMapping msdt:dt="string">'AboutMe':'AboutMe','AccountName':'AccountName','BaseOfficeLocation':'BaseOfficeLocation','Department':'Department','HitHighlightedProperties':'HitHighlightedProperties','Interests':'Interests','JobTitle':'JobTitle','LastModifiedTime':'LastModifiedTime','Memberships':'Memberships','PastProjects':'PastProjects','Path':'Path','PictureURL':'PictureURL','PreferredName':'PreferredName','Responsibilities':'Responsibilities','Schools':'Schools','ServiceApplicationID':'ServiceApplicationID','SipAddress':'SipAddress','Skills':'Skills','UserProfile_GUID':'UserProfile_GUID','WorkEmail':'WorkEmail','WorkId':'WorkId','YomiDisplayName':'YomiDisplayName','WorkPhone':'WorkPhone','PhoneExtension':'PhoneExtension'</mso:ManagedPropertyMapping>

15.  In <body><div id=”Item_Person”> tag, add var has_wphone = !$isEmptyString(ctx.CurrentItem.WorkPhone);
var has_ext = !$isEmptyString(ctx.CurrentItem.PhoneExtension);

Item_PersonDiv

16.  In <div id=”ContactInfo”> tag, add

<!--#_ if(has_wphone == true) { _#-->



<div id="WorkPhone">
<!--#_ var encodedwphone = $htmlEncode(ctx.CurrentItem.WorkPhone); var displaywphone = Srch.U.getSingleHHXMLNodeValue(hhProps, "WorkPhone"); if ($isEmptyString(displaywphone)) { displaywphone = encodedwphone } _#-->



<div id="WorkPhoneValue" class="ms-srch-ellipsis" title="_#= encodedwphone =#_"> _#= displaywphone =#_ </div>



</div>



<!--#_ } _#-->
<!--#_ if(has_ext == true) { _#-->



<div id="PhoneExtension">
<!--#_ var encodedext = $htmlEncode(ctx.CurrentItem.PhoneExtension); var displayext = Srch.U.getSingleHHXMLNodeValue(hhProps, "PhoneExtension"); if ($isEmptyString(displayext)) { displayext = encodedext } _#-->



<div id="PhoneExtensionValue" class="ms-srch-ellipsis" title="_#= encodedext =#_"> _#= displayext =#_ </div>



</div>



<!--#_ } _#-->

ContactInfoDiv

17.  Save Client_Item_Person.html, upload it to the Display Templates/Search gallery, and publish it

18.  From Search Center, type in a query term (ex: Executive)

19.  From ‘Site Settings’, select ‘Edit Page’

20.  Edit ‘People Search Core Results’ Web Part

21.  Expand ‘Display Templates’, select ‘Use a single template to display items’, select Client_People_Item, then select ‘OK’

22.  Check In and Publish the People Results page (PeopleResults.aspx)

Your results page should look similar to the following.  Note that the OOTB only displays Name, Title, and Department.

PeopleResults

On my next post, I’ll cover how to add the e-mail to People Results page.

Happy search editing.

Add Term Sets to SharePoint 2013 Search Refinement Panel

Leave a comment

Following my previous post on working in Search Center.  Now I need to add crawled properties to the Search Refinement Panel.  These crawled properties can be content types, custom columns, or term sets.  In this post, I’ll use term sets.

My term store has regions which has U.S. States within each region populated.  For this example, we’ll use the West Region.

TermStore

Here’s my list with region term sets used.  I called that column “Store Region”.

BookList

After the list is populated with some values, go to List Settings –> Advanced Settings –> Reindex List

Just to make sure I get the crawled properties without waiting for the next scheduled crawl, I started the incremental crawl.

I then mapped the managed property to the crawled property.  In this example, I used RefinableString02 managed property.

In the mappings to crawled properties –> Add a Mapping –> I typed region and clicked Find

CrawledPropertySelection

Here I selected, ows_Store_x0020_Region, after a full crawl, I can now see the values in this mapped property.

From Search Center, after typing in a search term –> Edit Page, Edit Refinement web part properties, click Choose Refiners

In the list of Available Refiners, select RefinableString02 (this is what I mapped to in my earlier step).  Here, the list of available values displayed in the preview.

RefinableString02

Click Add –> Type a meaningful name in the Display name text box.  In my case “Store Region”, click OK to close the refinement configuration window, then click OK to close the web part properties window.  Check-in and publish the page.

Here’s the end product.

RefinementPanel2

Heartland SharePoint Conference 2014

Leave a comment

Mark your calendar for May 15, 2014!

As a Managing SharePoint Architect, it’s important to me to learn all that I can about the new SharePoint releases. My first SharePoint 2013 project started in November 2012 and I have learned a lot (and still learning). So have many of my colleagues at ICC.

That’s why I’m inviting you to attend the upcoming Heartland SharePoint Conference that ICC is once again sponsoring. It will be held at the Columbus Convention Center on May 15, 2014.

This conference will not only feature tracks of particular interest to architects, it will also provide information and advice related to other aspects of SharePoint 2013, with emphasis on:

  • Social
  • Mobile
  • Business
  • The Cloud

I was happy to learn that this year’s keynote speaker will be Steve Caravajal, Director of Digital Strategy and Architecture at Microsoft Corporation and co-author of the acclaimed book, “Professional SharePoint 2013 Administration.” I’m really looking forward to hearing what he has to say.

Please remember that because this is a free event, limited attendance is available onto qualified IT and business professionals. Be sure to send in your request as soon as we post information on ICC’s web site.

I’ll be at the conference and I hope to see many of my blog readers there, too!

Older Entries