This project has moved. For the latest updates, please go here.

MakeReadOnly truncates field values if finds any special characters like '&'

Oct 29, 2015 at 8:31 PM
Edited Oct 29, 2015 at 8:34 PM
This utility is really really great and saves life.. Found only one minor issues with what I have used so far. I am making a single line text field read only using the below function call, and if finds a special character like "&" in the value it truncates the string beyond & and display only characters before &.

Example -
SPUtility.GetSPField('CustomerCode').MakeReadOnly();
CustomerCode = "R&DI"
When form is displayed is only displays R and not R&DI

Tried debugging the sputility's code with no luck, any help or direction you could provide? Thanks in advance.
Coordinator
Nov 1, 2015 at 10:46 PM
Edited Nov 1, 2015 at 10:47 PM
Thanks, glad to hear you've found it useful.

I tried this in SharePoint 2013 using Chrome and it worked OK. Can you describe the environment you are working in?

If you try running this does it work?
SPUtility.GetSPField("CustomerCode").SetValue("R&DI").MakeReadOnly();
Nov 3, 2015 at 8:24 PM
Aah!! I see.. appears it displays the value in read-only field just correct in in Chrome, doesn't works in IE 11, it gets truncated for some reason. Have to find a solution for IE.

However the values like ''R&D'' are stored in a list and are supposed to be read only, so could not set on the fly.
Coordinator
Nov 4, 2015 at 2:56 PM
I am still unable to reproduce this (IE 11 + SharePoint 2013) but the value must need to be HTML encoded. I could make that change and then have you test to see if it works for you?
Coordinator
Nov 4, 2015 at 6:55 PM
I made a small change to SPUtility.js and uploaded them here: https://drive.google.com/folderview?id=0By7Fv_NvLfOYd3V3UXJpM2lLNWM&usp=sharing.

Can you try it out and let me know if this solves your issue?