0

I have developed some modifications against SharePoint list new/edit forms using CSR, as many other times everything works as expected. Code has been tested in two different environments and works.

What I believe that it's happening is that SharePoint is not rendering on the page the associated JS objects and instructions needed for CSR.

All environments are on premises, they are not online.

My code register modifications as usual with code like this (simplified ):

     var mods = {};
     mods.Templates = {};
     mods.Templates.OnPostRender = function() { alert() };
     mods.Templates.Fields = {
       "Project": {
             "NewForm": function() { alert() };,
             "EditForm": function() { alert() };
        }
     };

     SPClientTemplates.TemplateManager.RegisterTemplateOverrides(hiddenFiledContext);

But callbacks never executes... there are no errors no warnings on console, SPClientTemplates and TemplateManager exists and they are not undefined.

Comparing between environments I saw that sites where CSR works, inside html exists some JS like:

var WPQ4FormCtx = {"ListData":{ ... }} // form properties like fields context field values...
var form = SPClientForms.ClientFormManager.GetClientForm('WPQ4'); 
if (form != null) 
    form.RenderClientForm(); // i believe that this  function internally calls CSR 'magic'

This is code is missing, on one environment, don't know why or hoy to "activate" it

NOTE:

  1. EditorWebPart has CSR Render Mode configuration set to StandardLayout.

  2. Also on the site people pickers look old they are not client side people picker.

Am I missing something or any feature activation? I thought that CSR works OOTB.

Thanks in advance.

2
  • Which version of SharePoint (e.g. 2013, '16, '19) are you working with? Also, is your CSR code added directly to a page via a Script Editor or Content Editor web part, or is it being inserted into a List View web part's JS Link property?
    – Thriggle
    Commented Jan 30, 2020 at 19:09
  • It's a Sharepoint 2016, but environment has been upgraded since 2007. My script is added through a site Script Link because customization is needed in many lists. By the way the problem is not about script registration. We are investigating and i turns out that this concrete environment is the only one that is different, it seems that is more related on site template or some thing else.
    – Alberto
    Commented Jan 31, 2020 at 8:02

1 Answer 1

0

Finally we found that there was a third party software that was not correctly installed.

This software was hooking default Sharepoint templates anf for some reason caused that editor webparts uses Sharepoint's 2010 rendering instead of 2016's.

Old people pickers was a clue that something was wrong with the site.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.