PowerShell Error When Restoring Site Collection

SharePoint doesn’t allow the backup of a site collection and restore it in the same content database. If you backup a site collection and restore it, it will give you the following error.

So you need to make a new content database in the web application (in case the replication of the site collection at the same content database) so that the backed up site collection and the restored one are in different content database, but be careful to put the first database offline before you restore the new site collection.

 

HTML6 .. Already?

There have been a lot of buzz on the internet about the release of HTML6,  and seems like it’s going to replace a lot of stuff we used to do with JavaScript (if it’s approved) .. more than HTML5 could do.

The idea is to have <FIXTURES> tag in the Head tag of the HTML page, this Fixtures tag is a repository of code, each code block is called a model, and this model can either be static or it can be retrieved dynamically from SQL. These fixtures are then referenced in the body tag. So in the body tag of your HTML page you can reference chunks of HTML content that was declared previously in the Head tag, which can be static or dynamic, without needing JavaScript. This seems to be the replacement of the Single Page Application model (SPA) that’s currently implemented using some JavaScript frameworks such as Angular. So each part that will be changed will be inside a model in the Fixtures tag.

To read the proposal for the HTML6, have a look here:  https://lists.w3.org/Archives/Public/public-whatwg-archive/2015Mar/0071.html

Client Side Rendering in Forms In Depth

 

SharePoint gives new capabilities that developers can use to do same tasks required in previous versions of SharePoint using client side technologies. The main capability introduced in SharePoint 2013 is CSR (Client Side Rendering). The most common used method for CSR way is to manipulate users data for fields or list views.. But what about forms?

Someone is going to say: “Yes, SharePoint provides JS Link property for list forms as well, so what’s new with it?” Well, there’s more into it. Let’s see what can be done in list forms and to what extent we have the flexibility to do the forms we want.

Here we have a list called Customers, with a new form that looks like this:

 

csr1

Now, we want to make this look different, so we’ll be using JS Link for that. If you edit the newform page, and edit the web part:

csr2

Then go to Miscellaneous, you will find three important properties there:

  1. Form Template Name
  2. JS Link
  3. CSR Render Mode

 

csr3

 

We know that with JS Link we will be able to add a JS file and manipulate our form’s design. We also know that CSR Render Mode being set to standard it tells SharePoint to renders the form using CSR, and setting it to Server Render will make it depend on XSLT for that. But what about Form Template Name and its ListForm value?

If you had experience with SharePoint customization from previous versions specially for forms, you know that SharePoint uses technique called: Rendering Templates. Which is a group of predefined templates SharePoint has and uses them to render its pages and forms. If you have an on premises environment, you can go to this path: SharePoint Hive\TEMPLATE\CONTROLTEMPLATES, you will find a file called: DefaultTemplates.ascx:

csr4

 

If you open that file, you will find many controls with the tag: <SharePoint:RenderingTemplate.. . If you search for ListForm, you will find that it’s actually a rendering template that SharePoint uses to render its forms. But the good thing to know is, you can use another value which is CSRListForm. But what’s the difference?

The difference is that ListForm renders everything for you from SharePoint, like the layout for the form, the label names and so on, so if you need to use JS Link to style your list forms while you are using ListForm rendering template, you would need to use jQuery to restructure your HTML. So what if we use CSRListForm instead? Your list form would look like the following:

csr5

It will only render the fields for you, no labels, no buttons, no spaces between fields, nothing.. just fields. So you will have a clean output that you can play with in JS Link as much as you like! That’s neat!

Now let’s add a JS Link property to a .js file and try to style our form, there’s a file that my friend Muawiyah Shannak created and posted on MSDN, you can download the JS Link file here: https://code.msdn.microsoft.com/office/CSR-code-samples-11-Fully-54ebcaa6

Here we are declaring the objects necessary to form our view:

 

Inside the viewTemplate function we have the following code:

 

As can be seen, we’re constructing the HTML for our form, for this article and on MSDN, we made it static just for learning and explanation purpose. You can do whatever technique you prefer to form the HTML.

Three things to note about this code:

  1. Note how we have {{placeholders}} for each field we want to add in our HTML.
  2. Note also the getSPFieldRender function, I’ll explain that later on.
  3. The input button has an onclick function = SPClientForms.ClientFormManager.SubmitClientForm(‘{{FormId}}’) . This will allow us to use the out of the box capabilities to leverage the submit action and handling validations in the form.

Back to getSPFieldRender, this will go look into the form for each field by its internal name, and will get this field’s HTML, which will be replaced instead of the place holders such as {{TitleCtrl}}. This happens by using the CurrentFieldSchema and drilling down to the Field’s HTML from the ctx.Templates.Fields, As shown below:

 

Now, when apply this JS Link to our list form, SharePoint will render the fields, and place them instead of our placeholders, it would look like below:

csr6

Without using any jQuery hacks, you can now apply your designs to your list forms with the use of CSRListForms.

Hope that gave more understanding to List Forms and CSR.