question

AnthonyR-7075 avatar image
0 Votes"
AnthonyR-7075 asked CaseyYangMSFT-4714 commented

[SP2019] Set list's field JSLink property

Hi,
Is anyone able to set the JSLink property of a list's field in SharePoint 2019 ?
When I'm trying to do so, no exception is thrown but the property isn't updated.
I have a feature receiver doing so that works in SP2013 but not in SP2019.
I also tried with PowerShell, on a totally different SP2019 environment, but the result is the same : no error but property is not updated.
Thanks.

sharepoint-devoffice-sharepoint-server-developmentoffice-sharepoint-server-customization
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

CaseyYangMSFT-4714 avatar image
0 Votes"
CaseyYangMSFT-4714 answered CaseyYangMSFT-4714 commented

Hi @AnthonyR-7075,

You have to build SharePoint Framework extensions instead of JSlink. Within the "modern" UI of SharePoint Server 2019 most of those customizations are no longer available. SharePoint Framework extensions enable you to provide similar functionality in the "modern" UI.

1.Create a new SharePoint Framework solution
2.Define the new Field Customizer with JavaScript
3.Test the solution in debug mode
4.Define the new Field Customizer with TypeScript
5.Package and host the solution
6.Bundle, package and deploy the solution
7.Install and run the solution

For Reference: Migrating from JSLink to SharePoint Framework extensions


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @CaseyYangMSFT-4714 ,

Thanks for your answer.
I know SPFx is the way to go for modern UI but the SP2019 farm I'm working on use classic experience and will not be migrated to modern UI.
If you run the following PowerShell script in SP2019 :

 $web = Get-SPWeb http://myweb
 $list = $web.Lists["My list"]
 $field = $list.Fields.GetFieldByInternalName("MyField")
 $field.JSLink = "customCSR.js"
 $field.Update()
 $field.JSLink


What's the output of the last line ? (clienttemplates.js or customCSR.js ?)
Thanks for your help.


0 Votes 0 ·

Hi @AnthonyR-7075,

Here is a simliar thread for reference: How to add JSLink to a field.
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

Set the JSLink to a field using JSOM:

193665-jsom.txt

0 Votes 0 ·
jsom.txt (625 B)