Home

Make SharePoint Online list columns read only based on yes/no checkbox

%3CLINGO-SUB%20id%3D%22lingo-sub-1382606%22%20slang%3D%22en-US%22%3EMake%20SharePoint%20Online%20list%20columns%20read%20only%20based%20on%20yes%2Fno%20checkbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1382606%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%207%20columns%20that%20I%20need%20to%20make%20Read%20Only%20(greyed%20out)%20as%20soon%20as%20the%20item%20is%20saved%20when%20%22Field%207%22%20is%20ticked%20(yes%2Fno%20checkbox%20column).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20managed%20to%20make%20these%207%20columns%20read%20only%20using%20the%20following%20Javascript%2C%20however%20I%20am%20struggling%20with%20the%20IF%20statement.%20Any%20help%20would%20be%20appreciated.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%3CSCRIPT%3E%0A%2F%2F%20A%20%24(%20document%20).ready()%20block.%0A%24(%20document%20).ready(function()%20%7B%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%201'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%20%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%202'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%203'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%204'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%205'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20jQuery(%22textarea%5Btitle%3D'Field%206'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20jQuery(%22input%5Btitle%3D'Field%207'%5D%22).attr(%22disabled%22%2C%20%22disabled%22)%3B%0A%20%20%20%20%7D%0A)%3B%0A%3C%2FSCRIPT%3E%0A%0A%3CSCRIPT%20language%3D%22javascript%22%3E%20%24(function()%7B%20%24('a%5Bonclick*%3D%22clickDatePicker%22%5D').css('display'%2C'none')%3B%20%7D)%3B%20%3C%2FSCRIPT%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1382606%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1383027%22%20slang%3D%22en-US%22%3ERe%3A%20Make%20SharePoint%20Online%20list%20columns%20read%20only%20based%20on%20yes%2Fno%20checkbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383027%22%20slang%3D%22en-US%22%3EWhat%20about%20customizing%20the%20list%20form%20with%20PowerApps...by%20the%20way%3A%20are%20you%20using%20the%20classic%20experience%20of%20SPO%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1383114%22%20slang%3D%22en-US%22%3ERe%3A%20Make%20SharePoint%20Online%20list%20columns%20read%20only%20based%20on%20yes%2Fno%20checkbox%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1383114%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F60%22%20target%3D%22_blank%22%3E%40Juan%20Carlos%20Gonz%C3%A1lez%20Mart%C3%ADn%3C%2FA%3E%26nbsp%3B-%20we%20have%20considered%20using%20PowerApps%2C%20however%20due%20to%20several%20different%20factors%20we%20have%20decided%20against%20it%2C%20one%20being%20the%20high%20urgency%20of%20this%20request%20and%20the%20lack%20of%20experience%20we%20have%20in%20house%20of%20building%20PowerApps.%20The%20list%20we%20have%20currently%20works%20well%20in%20terms%20of%20user%20experience%2C%20so%20ideally%20want%20to%20keep%20it%20as%20similar%20as%20possible%20to%20how%20it%20currently%20is.%20If%20PowerApps%20is%20the%20only%20way%20then%20we%20will%20need%20to%20revisit%20this%2C%20but%20would%20be%20ideal%20if%20we%20could%20add%20some%20Javacript%20to%20the%20page%20to%20achieve%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20using%20modern%20experience%2C%20however%20the%20NewForm.aspx%2C%20EditForm.aspx%20and%20DispForm.aspx%20pages%20have%20all%20reverted%20to%20classic%20experience%20due%20to%20us%20having%20several%20script%20editor%20web%20parts%20embedded%20into%20each%20one.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have 7 columns that I need to make Read Only (greyed out) as soon as the item is saved when "Field 7" is ticked (yes/no checkbox column).

 

I have managed to make these 7 columns read only using the following Javascript, however I am struggling with the IF statement. Any help would be appreciated.

<script>
// A $( document ).ready() block.
$( document ).ready(function() {
    jQuery("input[title='Field 1']").attr("disabled", "disabled"); 
    jQuery("input[title='Field 2']").attr("disabled", "disabled");
    jQuery("input[title='Field 3']").attr("disabled", "disabled");
    jQuery("input[title='Field 4']").attr("disabled", "disabled");
    jQuery("input[title='Field 5']").attr("disabled", "disabled");
    jQuery("textarea[title='Field 6']").attr("disabled", "disabled");
    jQuery("input[title='Field 7']").attr("disabled", "disabled");
    }
);
</script>

<script language="javascript"> $(function(){ $('a[onclick*="clickDatePicker"]').css('display','none'); }); </script>

 

2 Replies
Highlighted
What about customizing the list form with PowerApps...by the way: are you using the classic experience of SPO?
Highlighted

@Juan Carlos González Martín - we have considered using PowerApps, however due to several different factors we have decided against it, one being the high urgency of this request and the lack of experience we have in house of building PowerApps. The list we have currently works well in terms of user experience, so ideally want to keep it as similar as possible to how it currently is. If PowerApps is the only way then we will need to revisit this, but would be ideal if we could add some Javacript to the page to achieve this.

 

We are using modern experience, however the NewForm.aspx, EditForm.aspx and DispForm.aspx pages have all reverted to classic experience due to us having several script editor web parts embedded into each one.