4

I have the following JS link , which i have added to classic interface inside our sharepoint on-premises 2013:-

(function () {

      function registerRenderer() {
        var ctxForm = {};
        ctxForm.Templates = {};

        ctxForm.Templates = {
            Fields : {
                'LinkTitle': { //------ Change Hyperlink of LinkTitle
                    View : function (ctx) {
                        alert("123");
                        if(ctx.CurrentItem.SiteCreated != null && ctx.CurrentItem.SiteCreated === 'Yes'){
                        var url = String.format('{0}{1}', "/sites/projectmanagement/", ctx.CurrentItem.ID);
                        return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, ctx.CurrentItem.Title);
                        }
                        else
                        {
                            var url = String.format('{0}{1}', "/Lists/projects/DispForm.aspx?ID=", ctx.CurrentItem.ID);
                        return String.format('<a href="{0}" onclick="EditItem2(event, \'{0}\');return false;">{1}</a>', url, ctx.CurrentItem.Title);
                        }
                    }
                },
            }
        };
        SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctxForm);
    }
    ExecuteOrDelayUntilScriptLoaded(registerRenderer, 'clienttemplates.js');


})();

then i reference it as follow inside the list view:-

enter image description here

now the JS link will modify the item url base on a custom column value. When i migrated the site to sharepoint online, the JSLINK will work perfectly on classic interface, but if i switch to modern interface the JSLINK will not have any effect. so can anyone advice if i can use my JSLINK to have effect on modern interfaces in sharepoint online? if the answer is No, then what are the approaches i can follow to achieve this ?

Thanks

2 Answers 2

5

In SharePoint Online modern interface list view, the JSLINK will not works.

We can use the column formatting to achieve your requirement, the following official document for your reference.

Use column formatting to customize SharePoint

3
  • looks like lot of steps, just to have list view formats ... second question, who will be able to add/modify column formatting? as i have noted that users with Read-Only permissions were able to add their own custom column formatting...
    – John John
    Commented Dec 11, 2018 at 12:12
  • Unfortunately, if the users only have Read-Only permissions, they can't add their own custom column formatting.
    – LZ_MSFT
    Commented Dec 12, 2018 at 1:32
  • so does contributor users have permission to add custom column formatting?.. if they can, then if i (as a sharepoint admin) add a custom column formatting, then any contributor user will be able to modify it?? this will be an issue..
    – John John
    Commented Dec 12, 2018 at 2:20
0

JSLink does not works on modern interface, it is default disabled. Microsoft is advising to migrate your JSLinks to SharePoint Framework Field Customizers/SharePoint Framework Extensions.

Microsoft has also published the article on their official documentation site. You may check here:

Migrating JSLink customizations to SharePoint Framework Field Customizers

Migrating from JSLink to SharePoint Framework Extensions

Going ahead all SharePoint Online customizations will be more SharePoint Framework centric.

An extract from above 1st article:

One of the main benefits of migrating old-school JSLink customizations to the SharePoint Framework is that it is the only supported technique that you have on modern sites for customizing the UI of "modern" lists and libraries. In fact, the "modern" lists and libraries, because of their rendering infrastructure and because of the no-script flag enabled on the "modern" sites, can't rely on old-school JSLink customizations. Thus, if you really want to extend the "modern" UI, you need to upgrade to the SharePoint Framework.

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.