20.10.2010 Updated code to add some more features: Edit list properties: “Hidden”, “ShowUser”, “Ordered”, “Direction”. Field properties: ShowInDIP (document information panel) and cross site lookup functionality for a standard SharePoint lookup column. The article is updated and describes the changes.
This code enables you to edit the following using javascript/jQuery only
List properties:
- Hidden: Hide the list so that it does not appear on the Documents and Lists page, Quick Launch bar, Modify Site Content page, or Add Column page as an option for lookup fields.
- ShowUser: Specify that names of users are shown in “Created by” and “Modified by” fields.
- Ordered: Specify that the option to allow users to reorder items in the list is available on the Edit View page for the list.
- Direction: LTR if the reading order is left-to-right, RTL if it is right-to-left.
Field properties:
- Hidden: Specifies whether the field is displayed in the list.
- ReadOnly: Specifies whether values in the field can be modified.
- Required: Determines whether the field requires values.
- Show In NewForm: Specifies whether the field is displayed in the form that is used to create list items.
- Show In DispForm: Specifies whether the field is displayed in the form for displaying list items.
- Show In EditForm: Specifies whether the field is displayed in the form that is used to edit list items.
- Show In DIP: Specifies whether the field is displayed in the “Document Information Panel” in compatible Microsoft Office applications. Only available for document libraries.
- Show In List Settings: Specifies whether the field is displayed in the page for customizing list settings.
- Show In Version History: Specifies whether the field is displayed in the page for viewing list item versions.
- Show In View Forms: Specifies whether the field is displayed in pages that are used to view list data.
- Lookup column web and list association (cross site lookup): Change the web and list association for a lookup column – Note: If you do this, all existing elements in this column will be lost. The cross site option is only available for site collection administrators!
Images:
Disclaimer:
I have removed some list types and some column types, but be careful using this tool. Test this in a “test list” before you use it in your “production environment”. If you edit the wrong field, you could break the list. Use this tool at your own risk!
Create a WebPartPage, insert a CEWP, and paste the code.
You find the code here
Regards
Alexander
WOW, this is some powerful piece of code!
Superb piece of coding and nice work !!!
Thanks and I will defintely test it.
Hi,
this is exactly what i need and searched for the last week. But unfortunatly it doesn`t work.
I checked the path to the jquery file and it is correct, it also shows the changed column green when i click on the Save Button. But the changes doesn’t seem to be saved.
I selected a field in a Tasklist not to be shown on DispForm, but it is still there.
I use WSS 3.0 to test this.
Hi,
A bug… i had the wrong propertyName for “ShowInDisplayForm” – Code updated, thanks for spotting it!.
Alexander
I am missing the select list options
I just get a select list to start:
v3.2 below it
but not possible to select a list what am I doing wrong please help 🙁
Look at the developer console (hit F12 > Console) – any errors? – maybe missing link to jQuery?
Alexander
Hi Alexander:
This is superior work… again! Thank you-
Very nice work! thanks!
Hi Alex,
As always, you have created an amazing piece of code!
I have this code working as advertised except I am experiencing the diappearance of anything I set to ReadOnly.
Have I done something wrong?
This behavior is by design. This is “standard SharePoint behavior”.
Alexander
Hi Again,
Your code is some of the only ones I have found that WORK!
My apologies if I am wasting your time, but I am afraid I do not understand the ReadOnly working the same as Hidden. Can the ReadOnly be changed to Display only. For example I want users to SEE the fields contents but I don’t want them to be able to edit it. I am hoping that it could perform what the code below achieves.
Thank you very much!
Will
READ ONLY Code example
function check()
{
var elements=document.body.getElementsByTagName(“*”);
for (index=0; index < elements.length;++index)
{
if(elements[index].tagName=="INPUT" && elements[index].type=="text" && (elements[index].title=="MTGID" || elements[index].title=="PRJID" ))
{
elements[index].readOnly=true;
}
}
}
_spBodyOnLoadFunctionNames.push("check()");
Hi,
The code in the original post can not do this, but look at this one Get field value for all SharePoint FieldTypes or set field as read only in EditForm
Alexander
Code updated to support editing of the “Title” field.
Alexander
Small fix regarding showing the title field. Changed the field name to “DisplayName”.
Alexander
Fantastic! Is it possible to use this to “Show in Alerts”? I haven’t been able to find anything to help control the appearance of alerts and my html calculated columns show up there and look terrible. Thank you for all that you do!
That’s an amazing post. Thanks a lot
Terrific Job, It is one of the best post. Can you please let me know how can i hide or remove Title, All Day Event, Recurrence, Workspace fields from Calendar. I dont want this feilds to show up in any of the forms i.e new, dispform, allitems, edit.
I really appreicate if you could quickly post some solution to it.
Hey John, this is a fairly simple code using what Alexander has already posted. If you start to familiarize yourself with jQuery it will get easier. When you implement this code make sure of 2 things. Node of the fields you hide are set to required. and add this to all 3 forms (New, Disp and Edit)
update your src reference
wow this is really cool .. i m new into sharepoint and coding is a bit tough job form me .. sorry to bother u but can u plz tel why cant we use server side code .. as dis is so tough
Hi, Server side code is no problem to use if you have access to the server. In *most cases* the end user does not have access to put files on the webserver.
Alexander
plz tel, will i have to put it in sharepoint designer?
No need for SharePoint designer, just put the code in a CEWP in a webpartpage.
Alexander
Great script… I liked it very much, it solved my big problem… ::YOU ARE MY FIRST SHARE POINT GURU(TEACHER)::
Thanks for sharing the great script.
A quick Query: Could you please tell me how to only display my own lists? how do I get the number of my list as you written in script?
var arrTypesToSkip = [‘110′,’111′,’112′,’113′,’114′,’115′,’116′,’117′,’118’];
Hi,
Sorry for the late reply, but your question drowned in all the emails and comments…
These are not lists, but list types. I’m not sure what you mean by “your own lists” as the list does not have any records of the user who created it.
Alexander
Hi Alex
Great script. Can you advise why Calculated Field type do not show? I’m using some Text2HTML stuff and I don’t want fields like ‘Color’ to show up. I’m having to edit the forms individually to hide the field and it would be good if I could manage them through this script.
Look at line 213 in the script. If you remove “Calculated” from the “arrOfTypesToSkip” you will see your calculated fields alongside many “system fields”. You better not change the “system fields” as you can end up messing up the list for good.
Alexander
Thank you so much for your solution! I have been scraching my head for a while now and found this… Amazing!!! I do have a question: Once I set a field to “read only” it is not listed in edit mode. Is there a way around that?
Best Regards,
M
Hi, This is how it works by default in SharePoint. The read only property does not apply for editform only. If it is set – the field is more or less unusable…. Look at this article for another approach
Alexander
gud article. i have one query like there are 2 users ie user1 and user2.
the user 1 should have to enter or edit xyz
and user 2 should have to enter or eidt abc.
is it possible? Please suggest how to do it.
Hi,
This is a power user / site collection administrator tool, but if the user is not site collection administrator, setting the list permissions might work (if xyz and abc is lists).
Alexander
This is great — and works great on an HTTP site. Does anyone have any experience or suggestions to get it working on an HTTPS site? Changing the references to HTTPS in the JS didn’t help me. 🙂
Thanks.
-Ray
Hi Alex.
Does it work on SharePoint 2010?
Thx.
Hi,
Yes, the field-properties part does.
Alexander
will this allow me to create a lookup column on a subsite and bring that to a form on the parent?
I created a test list.
It looks like it will let me pick a subsite.
But nothing has changed on my test list. Is there some other step I’m missing?
Hi,
Look at this article: Convert a standard SharePoint lookup column to a full blown cross site lookup using javascript only
Alexander
It’s a brilliant bit of code. Unfortunately in SP 2010, you set a field to read only and display in editform, and it no longer appears in editform. Seems like an SP bug to me.
So all I could do was make a new edit form (which is detached sadly – won’t reflect future column changes) then edit the field settings in SharePoint Designer.
Hi,
This is the default behavior for a read only field. This tool adds nothing more then the ability to toggle the already existing (but hidden) attributes for the fields.
Look here for another approach
Alexander
I’m not sure that this resolves the problem, sometimes we need to see some fields in edit form, sometimes this is part of requirements
Hi,
This solution either hides or shows the field. You should look at some other solutions in stead.
One example is found here
Alexander
Hi!
Thanks for script. But i can download it from https://bautz.homeserver.com/SharePointJavascript/Scripts/ChangeListAndFieldProperties/
It says timeout error for any browser.
How i can grab your code?
Thanks.
I have updated the link. The redirect from my old server was down.
Alexander
Hi
i want to hide some columns in edit view.
Thanks
Shruti
Hi,
This code will do that for you – are there any problems?
Alexander
This is freaking cool. Thanks for posting.
I was trying to set the Hidden property to Yes for several system created Libraries like “Site Collection Documents” and “Site Collection Images” which are part of the “Publishing Resources Feature” and I get an Error Occured response from the script. Is that expected? Thanks!
Hi,
Sorry for the late reply. I’m not familiar with the “Publishing Resources Feature”, but it might be that these columns are not editable.
Alexander
Hi,
I’ve tried to implement your solution, but get “Web selector not available” in the ‘lookup column list association’ column, so can only choose a list on the same site collection. Any idea what is causing this and how, if at all, I can fix this? PS I don’t have access to the server. Thanks.
Paul
I am getting same problem, Even I have site collection admin rights but got error “web selector not available”
Hi,
Is this on SP2007 or SP2010?
Alexander
Hi Alexander,
Thanks for looking at this. We use SP2007.
Hi Paul,
I’ll post a new “lookup relinker” solution later tonight.
Alexander
Hi,
You find it here
Alexander
Hi Alexander,
Great solution, we used it in our SP project a lot, but now we moving to SP 2013, any plans for SP13 support?
Thanks))
Hi,
Have you tested it? – I have not tested it myself as I do not have access to a SP2013 site yet.
Alexander
Yep, i’ve tried it with sp13, but no luck. You can try it yourself with free office 365 developer membership http://msdn.microsoft.com/en-us/library/fp179924.aspx
WOW! You deserve a medal. Great job!
Thank you,
Alexander
Hi Alexander,
I created a CEWP on a web page and pasted the script onto it, expecting the joy that everyone here experienced–but unfortunately, no joy. The CEWP just displaed the text of the script and didn’t resolve the tags into a page like you displayed in your screen images above. Just everything from to
Next, I saved the script as EditFieldProperties.js file onto my computer and uploaded it to a document library on our SP site called Site Assets. I then referenced the path from the Site Assets library in the CEWP, and all that happend was a link to EditFieldProperties.js appeared on the CEWP.
I am sure it is some newbie thing I am missing. So any further detail would be greatly appreciated.
Thanks,
Richard
Hi,
You must put the code in the source editor, or link it using the “Content link” option in the CEWP.
I suggest you use the HTML Form web part as this has a source editor only.
Alexander
Thanks Alexander! The HTML Form Web Part actually worked.
The reason I needed this was because, for some reason, the built-in SP “Modified By” column was somehow set to Required. Well, when I got the script to work, the “Modified By” column and its properties are not being displayed. So, is the “Modified By” column somehow being filtered out by the script? If so, what changes do I need to make to the script so that I can see the “Modified By” column? I just thought that was the case because of the caveat at the beginning of the script (i.e. “I have removed some list types and some column types”)
Hi,
Yes, these fields has been removed. You can add them back by editing the script – change this line:
to
I do not think this will fix your problem, as this column is not set as required by default. Please be careful, you might break your list.
Alexander
Thanks Alexander! I will try that and be extra careful.
I am not sure either why or even how the “Modified By” column was set to “Required”. Any thoughts? In my search for an answer, Google has brought me here. Any other less riskier ideas or solutions.
I tried changing the Manage Content Type to “Yes” within the list’s Advance Settings and change the property there… but no such luck. When I open the list’s form in InfoPath, I still see the field as having a red asterisk for required. Saving a new record is impossible because the required constraint is being violated. So, I am desperate.
I’ll try this tonight.
Out of curiosity, worst-case scenario, how might a list be rendered broken by the changes made by the script?
Greate solution Alexander! You have done a great job here!
I have tested it on SharePoint 2010 and it works as described. Do You have any plans for converting it to SharePoint 2013? It would really be helpful
Regards, Magnus
Thank you,
I will have to redo it in not so distant future, but I cannot be more specific.
Alexander
Alexander,
Great job! I recommended it a lot.
Magnus,
To make it breathing in SP2013 just replace _spUserId with _spPageContextInfo.userId (http://spservices.codeplex.com/discussions/441982)
I haven’t tested full functionality but column properties are working. Obviously SP2013 specific properties are no available.
Regards,
Vladimir
I’m trying your script in SharePoint 2013. I’ve added a CEWP to the default new form and added a link to the JS file (in site assets) in the content link and I can click to load list collection and all I get is please wait while loading lists.
I did replace the two enteries _spUserId with _spPageContextInfo.userid.
Any Ideas?
Hi,
I used Script Editor to insert the script into the page and that worked for me.
Regards,
Vladimir
I also tried the script editor and I still get “please wait while loading lists”
Great posting. Is there a way to do a filtered lookup? I would like to only return values that meet a certain criteria in the lookup. thanks
Sorry, but I do not know a way to prefilter a lookup. I think you must go with a JavaScript solution. Search the archives for “lookup” to find possible solutions.
Alexander
Superb piece of code….
Hi Alexander, Im on SP 2013 and i put a reference to the code in a CEWP but there’s no lists on “select a list to start”.
Hi,
You must use this new version: https://spjsblog.com/2014/03/26/edit-sharepoint-field-properties-in-sp2010-and-sp2013/
Alexander