Sunday 20 January 2013

HTML Page Layout issue





I have been fortunate enough to travel to Vegas for SharePoint Conference 2012 in November 2012. It was a long journey and was full of SharePoint content. After coming back from conference I was given a chance to implement an intranet on the new SharePoint 2013 platform. This was a new intranet sitting on dev servers in SP 2010 and the intranet did not make it to prod servers. It made perfect sense to upgrade to 2013.
View from my room.


Well I was very excited about new features it had to offer and was the selling point. Well to be honest the straight upgrade had lots of hiccups and eventually I had to reconfigure the web application all over again in new environment. L

Moving on from there I have still encountered some issues thus this blog, so that if you encounter similar issue you can try these solutions.

The intranet I was developing was mostly OOTB configuration and design principle given was to leverage ability of product in following order:

1.       Always use OOTB features to address any requirement,

2.       If OOTB doesn’t satisfy the business requirement use Java Script and CSOM.

3.       Use the .net server side code as last resort (Timer jobs, workflows, event receivers etc.)

Problem 1:

The first issue I received was that the page layout was not rendering the taxonomy field and multi-line fields while the page is in published or save mode. In order words whatever value you select in edit mode and save the page, then the page will not render the selected value.


Workaround / Resolution:

I googled the problem I found out that I was not alone some more people had the same issue without resolution. I had an idea that it might be the old 2010 (upgraded 2013) Content Type Hub. So I asked SP admin in the organisation to create a brand new Content Type Hub in 2013 environment and recreate all the site columns.

Guess what! It fixed the Taxonomy rendering issue! However the multi-line / note field still had the same issue.

To come around that I recreated the column but this time selected the column type as “Full HTML content with formatting and constraints for publishing”.



While this is not a fix, just a workaround, It might get fixed in next SharePoint 2013 service pack. Also note that this field will take up much more space in the database.

Problem 2:

The second problem I encountered was that the Date-Time field when added to the HTML page layout (using Snippet Gallery in the new Design Manager), it would not allow page to be saved and throw up and error “Are you sure you want to leave this page?”


If you select either option, then the other mandatory metadata values lose their selected information and you have to enter them again L.

As you know in SP 2013 you have to edit the HTML page and .aspx page gets generated automatically. Therefore using the design manager snippet gallery I started creating the page again.


Now you must be wondering that how was I sure it was date time field which was making this issue?

Easy,

·         I got the snippet for every content type field from the snippet gallery.

·         Dropped the new field snippet on to my HTML page layout.

·         As soon as I dropped one field, I used to test the page layout by saving some dummy data.

·         I repeated these steps till I came across that it was the Expiry date and Review Date which was having some issue.

Now Since I cannot guess what is the issue in the system generated snippet? I had an idea.

<div data-name="Page Field: Expiry-Date"><!--CS: Start Page Field: Expiry-Date Snippet--><!--SPM:<%@Register Tagprefix="PageFieldDateTimeField" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>--><!--MS:<PageFieldDateTimeField:DateTimeField FieldName="f80d8fde-e7fb-4a29-8d3a-8ad6b90753a5" runat="server">--><!--PS: Start of READ-ONLY PREVIEW (do not modify)--><div align="left" class="ms-formfieldcontainer"><div class="ms-formfieldlabelcontainer" nowrap="nowrap"><span class="ms-formfieldlabel" nowrap="nowrap">Expiry-Date</span></div><div class="ms-formfieldvaluecontainer">21/01/2013</div></div><!--PE: End of READ-ONLY PREVIEW--><!--ME:</PageFieldDateTimeField:DateTimeField>--><!--CE: End Page Field: Expiry-Date Snippet-->

</div>


Workaround / Resolution:

On the snippet gallery I saw another button named “Custom ASP.NET Markup” .



When you click on this button I got an empty text box with two buttons (update & Reset) on RHS.




In the empty box I wrote the date time field as I would in old SP 2010 aspx page. i.e

<PageFieldDateTimeField:DateTimeField FieldName="Review-Date" runat="server"/>

And clicked on update button underneath. This refreshed the screen and on LHS panel I got a snippet with the following code in it.

<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->

<!--SPM:<PageFieldDateTimeField:DateTimeField FieldName="Review-Date" runat="server"/>-->

<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->

Now since the snippet is not complete unless you register the namespace. So I added one line on top of snippet.

<!--SPM:<%@Register Tagprefix="PageFieldDateTimeField" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->

So final snippet can be seen below:

<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->

<!--SPM:<%@Register Tagprefix="PageFieldDateTimeField" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->

<!--SPM:<PageFieldDateTimeField:DateTimeField FieldName="Review-Date" runat="server"/>-->

<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->


Last step: I added this snippet to my Page layout and tried saving a new page using this page layout. Wola! It saved and got published without any more annoying error!

I hope this workaround helps you if you are encountering the issue.

Please leave some comments if you have a better solution or would like to suggest anything better than what I have.



No comments:

Post a Comment