SharePoint Script: Hide or Disable your fields

This one has been on my list for a while. I’ve used a collection of JavaScript methods to help streamline customizing forms in lists. I have created and compiled this little collection starting probably 5-6 years ago, and over time I’m constantly updating, tweaking, enhancing it, especially more so as of late working with Office 365.

This script works on SharePoint 2013, 2016 and Online. I heard it works on 2010 as well, though I haven’t had much experience with it there. Let me know!

I have a lightweight JavaScript file which allows you to hide or disable (set to read-only) fields in a new or edit form. It’s pretty basic but is a big value add. Also, you can set a field to read-only for only certain groups, meanwhile allowing other groups to edit the field. You can also hide a field completely, as well as hide a field and only show it for certain groups. Pretty sweet right?

UPDATED 2/28/15 fix a few bugs as noted in the comments.

UPDATED 10/22/15 fix disableWithAllowance and people pickers.

UPDATED 10/23/15 fix disable and disableWithAllowance and metadata fields.

UPDATED 5/24/16 fix issue with disabling Lookup Fields, now will show correct value.

UPDATED 8/1/2016 fix issue with disabling choice fields as radio buttons, now will show the single selected value.

UPDATE 9/27/2017 not really a fix, but moving from CodePlex to GitHub

The script is here: download from GitHub.

How to use it

Include the script along with jQuery on your page. Ideally, throw this nugget into your master page and you can use it anywhere in your site.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="/SiteAssets/Lozzi.Fields.js" type="text/javascript"></script>

Once that’s in, get using it! It’s really simple, I threw this on my new form for my task list:

<script type="text/javascript">
 $(document).ready(function(){
  ExecuteOrDelayUntilScriptLoaded(function(){
 Lozzi.Fields.disableWithAllowance("Start Date", ["Project Managers"]);
 Lozzi.Fields.disable("Task Status");
 Lozzi.Fields.hide("% Complete");
 },"sp.js");
 });
</script>

This will change our New form for a typical task, from:

New SharePoint Task Form

to

New Task Form with Hidden Disabled Fields

See the difference? It’s subtle, but when working with end users, it can provide a huge benefit to help streamlining your business flow.

From here, you could have the edit form disable or hide a lot of the fields for normal users, only allowing your Project Managers, or if this is a support request list, your Support Team access to modify fields as needed. The options are endless.

More details

Lozzi.Fields.disable(fieldname)

Simply disables the field, for all users. It hides all controls in the field and displays the value instead.

Lozzi.Fields.disableWithAllowance(fieldname, groups)

Disables the field, but enables it for the users in the groups specified. Also, Site Collection Administrators are included automatically, so they can always edit the field. You can send the groups in an array, like [“Group One”, “Group Two”].

Lozzi.Fields.hide(fieldname)

Simply hides the field, for all users.

Lozzi.Fields.hideWithAllowance(fieldname, groups)

Hides the field, but shows it for the users in the groups specified. Also, Site Collection Administrators are included automatically, so they can always edit the field. You can send the groups in an array, like [“Group One”, “Group Two”].

Some other important notes

  • Currently, this script does not work on list views, meaning a user could edit the data in datasheet/quick edit view.
  • This script should work just as well on SharePoint 2010 if you so desire.

Download this script here: download from GitHub.

Til next time, Happy SharePointing!

Advertisements

136 thoughts on “SharePoint Script: Hide or Disable your fields

  1. Gary Stocker

    Hi David
    Love the script, really useful. Having a small problem though.
    I am using o365 and when I try to disable a ‘Multi Line Text’ field it, disables it and then just shows text, but then directly below it shows the text box.

    Any Idea what is going on here?

    Gary

    Reply
    1. Gary Stocker

      Hi David
      Further 2 my query above, this only happens for ‘Multiple line of text’ fields when they are ‘Rich text’ or ‘Enhanced rich text’ it does not happen for types of ‘Plain text’
      Thanks
      Gary

      Reply
  2. Paul

    Hi, I am new to SP. We are running hosted Office 365. I saved the .js file in Site Assets and put the script into my page but it’s not making any difference. It didn’t work for me but that may be because I am a Site Collection Admin but I’ve also checked with a user who is a normal user. I’ve tried DisableWithAllowance and Disable. Any ideas?

    Reply
  3. Paul

    Update: In addition to this not working, it removed the links at the top of the page for editing that page – the tabs for “Items” and “List”.

    Reply
    1. David Lozzi Post author

      Did you see my previous reply? Do you have jQuery? Are you seeing any script errors?

      Those tabs sound like tabs for a list view, and this script should be on a form for a list item, so those tabs shouldn’t exist at all.

      Reply
      1. Paul Guillou

        I. I followed your instructions and it seems that I have Jquery installed. I am getting erros though – SCRIPT 70: Permission Denied. I will email you a screen shot.

  4. gsot

    Hi David. I try to use your library and a have a strange problem (I am not familiar with jQuery and Javascript): In EditForm.aspx of a list i have used a script editor in which I have used the exact code:

    $(document).ready(function(){
    Lozzi.Fields.hide(“MyField”);
    });

    With the help of development tools of my browser i see that my page ‘views’ your library but it never runs the above script code. When though i run on debug console the whole script or just the command Lozzi.Fields.hide(“MyField”);… it works! Can you understand which is the problem?
    Thanks in advance!

    Reply
    1. gsot

      it worked! Don’ t be bother to deal with it. I dont know what was wrong! Thanks for your time! Please delete my post…

      Reply
  5. sonia

    Hi David, disableWithAllowance and hideWithAllowance doesnt work for me. i set up a group called developers on my site and have this code Lozzi.Fields.disableWithAllowance(“Assigned To”, [“Developers”]); however the field is disabled for everyone including me and i am in the developer group. any idea what im doing wrong?

    Reply
      1. sonia

        Hi David, I checked and there are no issues – i copied a sample of my script – maybe you will be able to see what’s wrong from this code

        removed code to save space on blog, please email it to david.lozzi at slalom.com

      2. David Lozzi Post author

        I’m not sure this is the right code, I see more SharePoint code than my utils in here. Can you email me the code at david.lozzi at slalom.com? Thanks!

      3. sonia

        It worked :) thank you for this amazing script and for your time helping me to troubeshoot my jquery issues

      4. Henry

        Hi, I have been having the exact same issue that sonia had with the disableWithAllowance function, the field is disabled for everyone include site collection admins. I tried adding extra alerts into the code and they are not being triggered in either the getGroupsAndEnable or asyncFailed functions, that makes me think it is something to do with the spContext not being set.

        If you have any ideas if would be great, this code looks very useful.

        Thanks
        Henry

      1. Chintan Sanghavi

        Hi David, I am also having the same issue mentioned by Sonia & Henry…The field is disabled for every group even I mentioned to allow for “Managers” group. Please help

    1. Letícia Freitas

      Hi Sonia, how are you?

      I’m having the same problem as you wirh disablewithallowance. Can you tell me, how did you solve this problem?

      Reply
  6. Manish

    Hi David,
    I have downloaded your script. But doesnot work with the lookup column.

    It hides the label but the drop down is still visible.

    Any idea on this one? How to hide the lookup column.

    Thanks & regards,
    Manish

    Reply
  7. Sid

    Hi David,

    I have downloaded and used your script from codeplex. Its great and it works perfectly ok for the simple “hide” and “disable” commands but fails when i try to use the “disableWithAllowance” and “hideWithAllowance”.

    I’ve performed the following steps with no luck.

    1. Created a simple named SP group called “DummyTEST” and added the test account to it.
    2. Added the code to a custom list form (edit form type)
    Code:
    Lozzi.Fields.disableWithAllowance(“Start Date”, [“DummyTEST”]);
    3. The “disableWithAllowance” and “hideWithAllowance” doesn’t work and it either disables or hides for everyone. Problem is similar to what was described by Sonia last month. I’m using “jquery-1.11.1.min.js” version of the jQuery file.

    I’ve also checked the error logs using the browser developer tools and it only throws warning message related to some body tags. Nothing that I could see related to this code.

    Any idea if i’m doing wrong?

    Thanks
    Sid

    Reply
    1. David Lozzi Post author

      Hi Sid,

      A couple of others have reported issues with the Allowance functions. I’ve retested and unfortunately continues to work fine here. If you’d like, we can connect remotely and I can see it in action on your computer. Email me, david.lozzi at slalom.com and we can coordinate.
      Thanks!
      David

      Reply
  8. Pavan

    Great post and perfect solution for my need but Weirdly it doesn’t work for me. SP 2013 Onpremise. Included the Jquery locan and Lozzi JS along with the small code in CEWP on all three forms but it doesnt work. Not even hiding or disabling. Any idea of the mistake i’m doing? I can send you the code if you wanna have a look.

    Reply
  9. Tim

    So, this sounds really interesting but I’m new to this level of customization and don’t really know where to put this on the page. I can’t stick it in the middle of the XSL in SPD (tried that) so I added a script editor web part on the new editform.aspx page and downloaded the .js file to the root site (also copied the js URL and pasted that into the snippet). Any other helpful links or tips to get me going? Thanks!

    Reply
      1. Tim

        I did add both snippets into one script editor web part. Looks like this:

        $(document).ready(function(){
        Lozzi.Fields.disableWithAllowance("Task Name", ["Project Owners"]);
        Lozzi.Fields.disable("Start Date");
        Lozzi.Fields.disable("Due Date");
        });

      2. David Lozzi Post author

        Try without the disableWithAllowance, others have been reporting that’s causing issues, but I can’t seem to get a legit error from it.

      3. Tim

        Still no joy, but I think I’m missing something fundamental that is shorthand for the pros. I went to my new form (progressEditForm.aspx) in SPD13, added a web part, and then went to the form in IE and edited the page. Created the script editor, added the snippets, tweaked the fields and URL, downloaded the js file from codeplex, uploaded it to root collection site assets, pasted the js URL into the snippet, verified jquery 1.9.1 is running in our environment. Am I missing anything?

  10. Remy

    I’m having trouble with DisablewithAllowance part. The following script error appears:
    “Unable to get property ‘get_current’ of undefined or null reference”

    Any ideas on what might cause this?
    If I could get this working om my Office 365 Site, that would be great!

    Reply
    1. Remy

      The undefined error has been solved(see code below), but now I’m facing the problem that the disableWithAllowance and hideWithAllowance are not working. There are no erros visible when debugging. Anyone who got these two working in Office 365?

      the normal hide and disable funtion works fine.

      $(document).ready(function(){
      SP.SOD.executeFunc(‘sp.js’, ‘SP.ClientContext’, sharePointReady);
      });
      function sharePointReady() {
      Lozzi.Fields.disableWithAllowance(“field1”, [“TESTGROUP”]);
      Lozzi.Fields.hideWithAllowance(“field2”, [“TESTGROUP”]);
      Lozzi.Fields.disable(“field3”);
      }

      Reply
      1. David Lozzi Post author

        Hi Remy,

        I got this to work on two of my o365 sites, however I’m noticing a trend. Any chance we could connect via Skype/Hangout and I could take a look at your screen and troubleshoot? Let me know via email, david.lozzi at slalom.com

        Thanks!
        David

  11. Scott Struessel

    David, I am also trying out this script and I am having problems with the disableWithAllowance and hideWithAllowance functions.

    Reply
  12. silvershare

    This is awesome. Thanks, David. I am going to especially like the the disable feature.

    One issue I ran into when testing this and can’t solve this is- when I have a column with parentheses it does’t seem to take any action on the field. Say I have “field (test) name” as my column name I have tried:
    1) Lozzi.Fields.hide(“field (test) name”);
    2) Lozzi.Fields.hide(“field_x0020__x0028_test_x0029__x0020_name”);

    What am I missing?
    Thanks

    Reply
  13. silvershare

    nvm, after searching and researching I found out that I have to use escape characters for that like this
    Lozzi.Fields.hide(“field //(test)// name”);

    worked like a charm. Thanks again for the wonder script!

    Reply
  14. sandesh

    nice one, I have an issue in office 365 sharepoint online people picker, It is not displaying just user name, It is displaying all details as shown blow. any way we can display only name in office 365?

    10;#sandesh m m,#i:0#.f|membership|sandeshmm@xchanging100.onmicrosoft.com,#sandeshmm@xchanging100.onmicrosoft.com,#sandeshmm@xchanging100.onmicrosoft.com,#sandesh m m,#https://xchanging100-my.sharepoint.com:443/User%20Photos/Profile%20Pictures/sandeshmm_xchanging100_onmicrosoft_com_

    Reply
  15. Ahsan

    I have also got the same issue that Lozzi.Fields.disableWithAllowance is not working properly. The field gets disabled for everyone. I noticed that few users had the same issue and they have found the solution; I would request those users to write details that how it had resolved.

    Reply
  16. RajasekharRajasekhar

    Hi David,
    I tried the script and it’s working fine. But Lozzi.Fields.disableWithAllowance(fieldname, groups) is not working for “People Picker” and “Date” field.
    Can you pl look into it.

    Reply
      1. Ann

        I am having issues with People Picker and the drop down fields as well. But the link you provided doesn’t seem to exist. Would you be able to send? I know I am late to the party. Will appreciate the help.

      2. Ann

        BTW, I was able to fix the PeoplePicker issue. I had to go to the Loozi.js and change ms-inputBox to ms-inputuserfield. That did the trick. Now if only drop down field can be fixed. Ah!

      3. David Lozzi Post author

        Thanks for the comments. I’m not sure what the issue is exactly :P. I just updated the script for a fix for People Picker and Metadata fields. Can you try this most recent version, also noting the update above to my sample script which includes waiting for sp.js.

  17. Letícia Freitas

    Hi David,

    I would like to know is this script works fine for any jquery version, or do I have to download the exactly same version that you are using?

    Sorry,

    I am new working with Jquery, this is my first time

    Reply
      1. Letícia Freitas

        Hi David. Thanks for your information. This solution works for SharePoint cloud? Using Office 365?

  18. Letícia Freitas

    Thanks Again for your answer David =)

    I have another doubt… I already add the Jquery to Seattle master page… is this correct?

    And which section of my script do I have to insert the lozzy script? Sorry… I am new in this cenario… before I used to work with WebServices in Infopath.. to disable field… which is very simple..

    I appreciate your help :)

    Reply
  19. Letícia Freitas

    look at the error I got

    Failed to load resource: the server responded with a status of 404 (NOT FOUND)
    New%20form%20v2.aspx:512 Uncaught ReferenceError: Lozzi is not defined
    $
    jquery.min.js:2 function (a,b){return new o.fn.init(a,b)}

    Reply
  20. Letícia Freitas

    Hello David … It’s Works fine now… Finnaly I got :0

    But as another users said, I am also having problems witht Lozzi.Fields.disableWithAllowance is not working properly. The field gets disabled for everyone.

    Do you have any idea ou new update for this?

    Thanks again for your support.

    Reply
    1. Letícia Freitas

      Obs: I’v already downloaded the new version of script (Lozzi Field No Site Col), and stil got the same issue… I’m site collection admin, and the field still disable for me.

      David, can you help me on this?

      Reply
  21. Dinesh Bagne

    Hi David,
    I’m trying to disable the choice field(radio button) but it’s not working properly. it will disable the field but will add extra text of “ctl100” before the Options. Please tell me how to deal with this.
    I have also got the same issue that Lozzi.Fields.disableWithAllowance is not working properly. The field gets disabled for everyone. I’m using latest Lozzifield.js

    Reply
      1. Suhas Yerramsetty

        David,

        I have your most recent code and am using it in a New Item page on office 365 version of sharepoint. But inspite of me being a site collection admin, still the people pickers are disabled for me on the form. Could you please help me on this.

        Thanks
        Suhas

  22. Maurice

    I have a custom list that contains a date time field. The client requested we trim the time portion of the field to only show two available appointment times of 8:30 am and 1:30 pm. In order to do this I added the following javascript code to the New and Edit forms of the list. The problem I am having is when the users open the edit form it does not maintain the previously selected time value. It shows the first available value of 8:30 AM, so if the users open the edit form and change some other field than the time field they inadvertently change the originally selected time field to 8:30 am even if the originally selected time was 1:30PM. How can I get the code to default to the originally selected time value from the New form within Edit form?

    $(document).ready(function () {

    var str=[‘8 AM’,’1 PM’];

    $(“select[id$=’_DateTimeField_DateTimeFieldDateHours’]”).each(function(i){

    $(this).html(“”);

    for(var i=0;str[i]!=null;i++){

    $(this).append(”+str[i]+”);

    }

    });

    });

    $(document).ready(function () {

    var str=[’30’];

    $(“select[id$=’_DateTimeField_DateTimeFieldDateMinutes’]”).each(function(i){

    $(this).html(“”);

    for(var i=0;str[i]!=null;i++){

    $(this).append(”+str[i]+”);

    }

    });

    });

    Reply
  23. Dorina

    Hi David,
    Thank you for your code.
    I dowloaded the last version of Codeplex and also the last version of jQuery. I am using SharePont 2013. The hide and disable arre working properly, however the disableWithAllowance is disabeling for everybody. Can you help please?
    Thank you

    Reply
  24. Gert

    Nice code.
    I have a checkbox. Once it is checked, it should be disabled in editform.
    Something like IF checkbox=true Lozzi.Fields.disable(“checkbox”)
    Is this easy to do? Can you help me with sample code?

    Reply
  25. Bill H

    Hello David, Thank you for an awesome script and the continued support with it. I have an issue that nobody has submitted yet. I’m using the script to hide with allowance for 8 columns. I’ve added it to the View, Edit, and New item pages. In IE, it works perfectly for all 3 pages. In Chrome and Firefox, it works for Edit and New, but only hides the first column (in the script) on the View pages. Any ideas?

    Reply
    1. Bill H

      Update: Using the console, I’m seeing the error, “TypeError: SP.ClientContext is undefined” Line 118 of Lozzi.Fields.Js.

      That ONLY happens on the View Item page.

      I’ll keep digging and let you know if I can get past it.

      Reply
  26. cjojucool

    Hi David,
    Thanks for the great script as with an O365 environment I was unable to modify the field behavior without using VS code.
    I did face some issues with integrating the script into my code.

    ISSUE 1: disableWithAllowance() and hideWithAllowance() were not working as expected. Some troubleshooting helped me determine that it was occurring due to SP.js not loading as expected. Comments here later validated my issue and it is now RESOLVED. Many thanks.

    ISSUE 2: A wait image is shown on the person or group field after disabling it using disableWithAllowance(). It works fine with using just disable().

    I can’t attach a screenshot here but will try and find your email and send them to you.
    Thanks for your help.

    Reply
    1. Suhas Yerramsetty

      Hi cjojucool,

      Could you please let me know how could you make disableWithAllowance() and hideWithAllowance() work on people picker fields. The script is disabling for everybody even if you are a site collection admin. let me know if you can shed some light on this issue.

      Thanks
      Suhas

      Reply
    2. David Lozzi Post author

      Thanks for the feedback. For ISSUE 1 I updated my sample code to wait for sp.js, is this the same method you used?
      For ISSUE 2, updated the code. Please grab latest and let me know!

      Reply
  27. nweber

    Hi David:

    Thank you for the script. Like other people mentioned hide and disable seem to be working great but disableWithAllowance and hideWithAllowance are throwing the following error (using this in a script editor web part at the top of EditForm):

    //group names in an array of strings, i.e. [“Group One”,”Group Two”]
    var disableWithAllowance = function (fieldName, groups) {
    disable(fieldName);

    spContext = new SP.ClientContext.get_current();

    Error = “Unable to get property ‘get_current’ of undefined or null reference”

    currentUser = spContext.get_web().get_currentUser();

    spContext.load(currentUser);
    spContext.load(currentUser.get_groups());

    I am running in a stock SP 2013 onprem environment, seattle masterpage, and referencing/using jQuery 1.10.2 (also working with 1.11.3):

    My redacted script/source is the following if it helps (known good/working calling hide and disable)

    http://servername/AI/jQuery/jquery-1.10.2.js
    http://servername/AI/jQuery/Lozzi.Fields.js

    $(document).ready(function(){
    Lozzi.Fields.disableWithAllowance(“field nema”, “SharePoint Group Name”);
    });

    Thank you for your help

    Reply
      1. nweber

        Hi David: I was also able to reproduce the issue on an Office 365 environment (no customization/stock team site, master page, etc. AFAIK) re: disable and hide WithAllowance.

        Thanks again in advance for your help.

      2. David Lozzi Post author

        Thanks for the comments. I updated the example script above, including a wait for the sp.js file. Shame on me :). Please try again with this change and let me know. I also updated the Lozzi.Fields script to fix People Picker and Metadata fields, grab the latest if you can!

  28. roy

    Hi David!

    I’m trying out SharePoint and needed to use your script. I was able to make it work on a sample list on O365. After editing the form using InfoPath, the script no longer apply to the fields. I even tried inserting the script in the “newifs.aspx” & “editifs.aspx” but doesn’t do anything. I tried running Lozzi.Fields.disableWithAllowance(“Status”, [“Group1”]); using Console and it returned Undefined.

    Any idea on how to enable the script in an InfoPath modified form?

    TIA
    roy

    Reply
  29. Roy

    Hi David!

    I was trying out SharePoint 2013 and needed to use your script. I was able to use your script on a sample list. After editing the form using InfoPath in changing the layout of the fields, the script no longer apply to the fields. I tried inserting your script in the “newifs.aspx” & “editifs.aspx” but it still doesn’t work. I used the Console to execute the script but it returned “Undefined”.

    Any idea on applying the script on a list modified in InfoPath?

    TIA,
    Roy

    Reply
    1. David Lozzi Post author

      Unfortunately this won’t work with InfoPath forms. Sadly we can’t do much with JavaScript and InfoPath forms. I created this script so we wouldn’t have to use InfoPath. Since you are, you can hide fields as you need and change the form layout with ease.

      Reply
  30. Gersom

    Hy David , Can You Please Help Me , Where I Must Put This Script , Because I am Try Put In Master Page , Not Working Please Detail me , Sorry I am Newbie in Sharepoint

    Reply
    1. David Lozzi Post author

      You have a couple of options. Putting it in your master page will let the code be available everywhere, but you’ll still need to put specific code on pages where you want to implement it. I usually use a Content Editor Web Part, linking to an HTML file which contains the code. Hmm.. not sure how much that helps. I’ll write up another blog post explaining how best to embed this code stuff, give me a couple of days ;)

      Reply
  31. Pingback: Embedding your JavaScript into a SharePoint page | David Lozzi's Blog

  32. Rod

    I see functions for show and enable, but I get a “not supported” when I try to call these. Are the function available? I would like to conditionally enable/disable fields based on form field selections.

    Reply
      1. Rod

        Thanks for the reply. Yes the libraries are referenced and the disable() and hide() methods function as expected. But I cannot get show() and enable() working. I am referencing jquery-2.1.4.min.js and using this in a SP2013 EditForm.aspx. Any suggestions?

      2. David Lozzi Post author

        show() and enable() are private functions, aren’t available from outside of itself. You can make them public by adding them to the return statement at the bottom of the script, like
        return {
        disable: disable,
        disableWithAllowance: disableWithAllowance,
        hide: hide,
        hideWithAllowance: hideWithAllowance,
        show: show,
        enable: enable
        }

      3. Rod

        Thanks David, I’ll try that. I am surprised no one ever had a need to show or enable a field after hiding it. Seems simple enough. thank you!

  33. Sajesh

    Hi David,
    Thank you for your code.
    I dowloaded the last version of Codeplex and also the last version of jQuery. I am using SharePont 2013. The disableWithAllowance option is working properly for the first column and rest of the column which i applied is not working on the same form, Can you help please?
    Thank you
    Sajesh

    Reply
  34. Tony

    Hi David,
    I just stumbled across your plug-in. Thanks for the script. I am having problems with the disableWithAllowance setting. I am a site collection admin and part of the specified group and still cannot access the field. I have verified that Jquery is loading. For the others that were having similar issues, what was the fix?

    Thank you!

    Reply
      1. Dawid

        Hi David,

        First of all thanks a lot for your awesome work you put into the community. Im having the same problem as few others, where Lozzi.Fields.disableWithAllowance does not work and disables the field for everyone.

        What i have tried:
        * Developer toolbar – no errors
        * Created new group – no effect
        * Tested on latest Chrome, IE, Edge – no effect

        System Spec:
        * Win 10 Pro PL
        * SharePoint Online Business Premium
        * SharePoint Online E3

        A beacon of hope or an element which could shed a bit of light into this mistery is that Lozzi.Fields.hideWithAllowance works as expected.

        Thanks in advance.

  35. Andrew

    Thank you for developing such a great tool.
    I’ve noticed one slight issue. When disabling a lookup field (drop down) the text is replaced by the lookup ID rather than the text. Is there any easy fix for this?

    Reply
  36. Arkadiusz Kloska

    Hi Dave, Thanks for a great tool. Also have a issue with disabling a lookup field (drop down) cause of thext is replacing by the lookup ID. Can you provide us an update recording to this issue?
    Regards

    Reply
  37. Hatem

    Hello David,

    Thank you for the great tool it was very useful to me.
    I read that some ppl got “undefined context” error as well as me, just surround the code with “ExecuteOrDelayUntilScriptLoaded” function and the issue will be gone.

    I also did many tests and found that allowance is not working against “System” account! but work with any other account even it has the same permissions on the site/list.

    Thank you

    Reply
    1. David Lozzi Post author

      System Account is something special, and you really shouldn’t be using it day to day. I suggest stop using an account that logs in as such.

      Reply
  38. essineden

    Hi David,

    I love how this made my life easier :)

    Is this possible in disabling the hyperlink field and just showing Click here? I tried the disable but It’s still showing the entire link. I was hoping I can change that to a link instead. (EditForm.aspx)

    Thanks again!

    Reply
  39. Prashant Gupta

    Hi David,
    Thank you for the great tool it was very useful to me.
    I’m trying to disable the choice field(radio button) but it’s not working properly. it will disable the field but will add extra text of “ctl100” before the Options. Please tell me how to deal with this.
    I have also got the same issue that Lozzi.Fields.disableWithAllowance is not working properly. The field gets disabled for everyone. I’m using latest Lozzifield.js

    Reply
    1. David Lozzi Post author

      I see the issue, and am working a fix now, however I don’t see ctl100 in my example. How many choice options do you have? Can you email me a screen shot? david.lozzi at slalom.com

      Reply
  40. Patrick

    Hello David,

    Thank you for your amazing work with your lozzi.fields.
    I experienced a little issue when disabling a Date/Time field.
    I use a Date/Time field with Date and Time. If I disable this field, it only shows the date but not the time.
    For Example:
    08/15/2016 12:00 AM is shown as 08/15/2106 if I disable this Date/Time field with Lozzi.Fields.disable(“Date/Time field”)
    Any idea how to solve this problem?

    Thank you!

    Reply
  41. Ted Wilcox

    This isn’t working for my site. I put the following into a Script Editor web part on the EditForm.aspx page:

    //ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

    /SiteAssets/Lozzi.Fields.js

    $(document).ready(function(){
    ExecuteOrDelayUntilScriptLoaded(function(){
    Lozzi.Fields.disable(“Title”);
    },”sp.js”);
    });

    The script is running. There are no errors in the console. I am using SharePoint 365. The title field still shows up. I am using Chrome as my browser. Am I missing something?

    Reply
  42. Martin

    Hi David,

    Thanx for your outstanding work,

    Like Patrick, I wonder how to be able to still see the time when disabling the date/time field.

    Reply
  43. Dedre

    Hi
    I am having an error with the disableLookupField.
    Disable works for all my other fields, but as soon as I add the disable to a field with a drop down list, it stops working for all of them.

    jquery-3.1.1.min.js:2 jQuery.Deferred exception: theControls is not defined ReferenceError: theControls is not defined
    at disableLookupField (/Scripts/Lozzi.Fields.js:75:21)

    Do you know what could be causing this?
    Thank you

    Reply
    1. Dedre

      I have now created a custom Edit form as we also needed to change to of the field name text colours. I now have the following issues:

      1) The lookup field is now disabled, but it only shows the ID, not the line of text.

      2) The people picker field now displays this way:
      21;#Name
      Enter users separated with semicolons.
      It worked on the default EditForm.aspx

      Are you able to assist with this?

      As an aside, is there a way that I could incorporate the colour change into this script instead of creating a new edit form?
      The columns I have are Task status (drop down list) and Comments (multiple line text field) I’d like on the form itself that the words “Task Status” and “Comments” be displayed in red.

      Thank you

      Reply
  44. Pingback: Customizing SharePoint’s Modern Lists’ Forms | David Lozzi's Blog

  45. Tammy

    Hello. Tried this, but /SiteAssets/Lozzi.Fields.js is “Not Found”. Has this changed or is this now defunct? Thanks.

    Reply
  46. Bob

    Thank you for this tool. I am disabling a lookup field and while the field is being disabled, it is displaying the ID and not the Title field of the lookup. Is it possible to display the Title field and not the ID?

    Reply
    1. David Lozzi Post author

      Hi bob – I wasn’t able to recreate the issue. The code as is appears to work. Can you email me at david.lozzi at slalom.com and we can troubleshoot further?

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s