How to set some or all SharePoint BDLC list columns / fields read-only?


The SharePoint Business Data List Connector is used to simply connect a SharePoint list with external LOB data, e.g. from databases, CRM or ERP systems.


SQL Server Cobbection to SharePoint List



Using the SharePoint BDLC, external LOB data, e.g. from databases, can be suplemented / mixed with manually edited content in the same SharePoint list. That means, you can add collaboration content to LOB content for example.


To prevent users from editing content, that come from the external data source, some or all SharePoint list columns / fields can be set read-only. You can use SharePoint access rights for this - or simply JavaScript.


To set a SharePoint column / field read-only in edit form please open the "editform.aspx" in SharePoint Designer.


If you know the column / field ID from source code (e.g. '4_ctl00_ctl00_TextField’) you can add the following script:


<script type=”text/javascript”>
function SetReadOnly()
{ var elements=document.getElementById(‘4_ctl00_ctl00_TextField’);
elements.readOnly=true; }


If you don't want to use the ID but the title, e.g. 'MyColumn', to set a SharePoint column / field read-only, you can add the following script:


<script type=”text/javascript”>
function SetReadOnly()
{ // find all the elements with tag Name as INPUT
var elements=document.body.getElementsByTagName(“INPUT”);
// loop through all the elements till we find an element with type text and title as name of our field
for (index=0; index < elements.length;++index)
{ if(elements[index].type==“text”) { if(elements[index].title==“MyColumn”) { elements[index].readOnly=true; } } } }


If you want to generall hide the "OK" button, that use a script like that:


<script type=”text/javascript”>
function SetHidden()
{var x=document.getElementsByTagName(”input”);
for (var i=0;i<x.length;i++){if (x.item(i).type==”button”&&x.item(i).value==”OK”){x.item(i).style.display = “none”};}}


Thanks Nishant Rana for these scripts. You'll find some more ideas in his Blog.


Ifoc for free trial product regsitration - Layer2 leading solutions

Register for free download.

Keep your Sharepoint in sync. Download and try today.

Contact Us Icon for Layer2 leading solutions

Questions? Contact us.

We are here to help. Contact us and our consulting will be happy to answer your questions.