SharePoint Tips and Scripts
When you need to innovate, you need collaboration. — Marissa Mayer
Have you ever needed a column is a list to be required based on a value chosen in another column? This can be done using the Validation Settings on the list. List validation allows you to check that a user has entered valid data or has entered all necessary data. This type of validation should be done at the list level. At the column level, a validation formula cannot refer to another column. To add more than one validation see additional instructions below. Let’s take the following scenario as an example to understand how this works. A user is filling out a status report. A standard question is “Do you have any deliverables due this week?” You want to make sure that if the user selects ‘Yes’, then you want to require them to list the deliverables that were due and their due dates. Create your columns: For this example I created the following two columns: “Deliverables” and “DeliverableDue”. Just like that no spaces or special characters. This is to follow column naming best practices. You can go back and rename them and add a description after you have setup the validation rule. Also note that if you have a multiple lines of text column, you will need to first create it as a single-text column and change it to multi after the validation settings have been created. Here is the formula you would use for your validation: =IF([Deliverables]=”Yes”,IF([DeliverableDue]””,TRUE,FALSE),TRUE) Let’s break down the formula so we can understand what it’s doing.
- The bold portion of the formula is checking to see if the value of Deliverables is equal to ‘Yes’: =IF([Deliverables]=”Yes”,IF([DeliverableDue]””,TRUE,FALSE),TRUE)
- If this validation passes and the selected value is Yes, then the next bolded portion of the formula ensures that DeliverableDue contains data. =IF([Deliverables]=”Yes”,IF([DeliverableDue]””,TRUE,FALSE),TRUE)
- Navigate to your List Settings and select Validation settings under the General Settings heading.
- On the Validation settings page where you can enter the above formula as well as a message you want to provide to your users if the validation check fails. Enter the formula in the Formula column and enter your message in the User Message column.
- Select Save.


To conditionally require data in more than one SharePoint column
To add an additional conditionally required field, you will need to use a nested if statement using the AND function and the ISBLANK function. You can write out your statement in Excel to make sure you get the syntax written correctly. Here is the formula you will use: =IF(AND(ISBLANK(DeliverableDue)=TRUE,Deliverable=”Yes”),FALSE,IF(AND(ISBLANK(ListIssues)=TRUE,Issues=”Yes”),FALSE,TRUE)) To continue our example from above, let’s say there are now two scenarios:- Are there deliverables due?
- Are there any critical issues to address?


Scenario: Sometimes you may need to limit the character length of a multiline text column to a certain number of characters. You can achieve this functionality using a Jquery script. Follow below steps to implement this functionality.
- Create a column with Data Type “Multiline Text” and select the plain text option.
- Copy the below script and save it as a .js file.
- If your column has a different name other than “Description” you will need to modify the script and replace “Description” with your column name.
- You will also need to update the alert message and replace “Your message…” with your own message that you want displayed when a user tries to enter more than the number of characters you set.
- Save the file to your Site Assets library.
- Since this script references the jquery-1.10.2.min.js file, you will need to download it and save it to the Site Assets library as well.
- Open the NewForm.aspx page for the list and add a Content Editor web part at the top of the page. You will also need to do this on the EditForm.aspx page.
- Edit the Content Editor web part and add a link to this script file.
- Save the page(s) and test entering text into the multi-line text box.
<script src=”/SiteAssets/JS/jquery-1.10.2.min.js” type=”text/javascript”></script> <script type=”text/javascript”> $(function(){ $(“textarea[title$=’Description’]”).keyup(function(){ var txtValue = $(“textarea[title$=’Description’]”).text(); if(txtValue.length > 200){ alert(“Your message…”); $(“textarea[title$=’Description’]”).val(txtValue.substring(0,199)); } }); });</script> |
If you want to map a SharePoint Document Library or List in Windows File Explorer so that you can access the files through Windows Explorer instead of through your browser follow the steps below. The Open with Explorer link is not available in the SharePoint List ribbon so you will have to follow the manual process listed below.
To map to a SharePoint Document Library:
-
- Navigate to the document library using Internet Explorer browser.
- Select the LIBRARY tab.
- Select the Open with Explorer link in the Connect & Export group in the Ribbon.
- When File Explorer opens, right click the Quick Access link in the left pane, then click Pin current folder to Quick Access.
To map to a SharePoint List:
-
- Navigate to the SharePoint List using Internet Explorer browser.
- Copy the URL up to the end of the list name but not “AllItems.aspx”.
- Open Windows File Explorer.
- Paste the URL into the file path field and then Enter.
- Double click on the Attachments folder.
- Right click the Quick Access link in the left pane, then click Pin current folder to Quick Access.
NOTE: If there are %20 characters in the URL, replace them with spaces as explorer will not know what to do with them.
Each list item is assigned a number and the documents that are attached to the list items can be found in a folder with the corresponding number.
Here are some examples of scripts I’ve used in designing SharePoint pages.
Hide SharePoint Page Title
- Create a CSS file with the following entry and upload it to the site in an accessible place (Site Assets library, for example):
- Add the Content Editor Web Part somewhere on the page.
- Click the down arrow, ‘Edit Web Part’, and under ‘Content Link’ enter the URL of the CSS file you uploaded. You may also want to set the ‘Chrome’ of the Web Part to ‘none’.
- Click ‘Ok’, save the page and title should now be gone.
- Duplicate this step on any pages that you want the page title removed.
#pageContentTitle {display:none !important;}
Remove padding on web part page.
.cell-margin {margin-top: 10px;margin-bottom: 10px;}
.tableCol-75 {padding-right: 15px; Width: 75% !Important;}
.tableCol-25 {Width: 25% !Important;}
.tableCol-50 {Width: 50% !Important;}
.ms-table .tableCol-50:first-child {padding-right: 15px;}
.tableCol-33 {padding-left: 15px;Width: 33% !Important;}
.ms-table .tableCol-33:first-child {padding-left: 0px;}
Hide Quick Launch/Navigation Menu on left to maximize page content.
#s4-leftpanel {display: none}
.s4-ca {margin-left: 0px}
Hide the “Recently Modified” on wikis
.s4-recentchanges{display:none;}
Hide the “I Like It” and “Tags & Notes” icons on the ribbon
.ms-socialNotif-Container {display:none;}
Wrap Promoted Tiles
.ms-promlink-body {width:100%}
.ms-promlink-header {visibility:hidden}
Limit Max Characters in Multi Line Text Column
Scenario: Sometimes you may need to limit the character length of a multiline text column to a certain number of characters. You can achieve this functionality using a Jquery script. Follow below steps to implement this functionality.- Create a column with Data Type “Multiline Text” and select the plain text option.
- Copy the below script and save it as a .js file.
- If your column has a different name other than “Description” you will need to modify the script and replace “Description” with your column name.
- You will also need to update the alert message and replace “Your message…” with your own message that you want to be displayed when a user tries to enter more than the number of characters you set.
- Save the file to your Site Assets library.
- Since this script references the jquery-1.10.2.min.js file, you will need to download it and save it to the Site Assets library as well.
- Open the NewForm.aspx page for the list and add a Content Editor web part at the top of the page. You will also need to do this on the EditForm.aspx page.
- Edit the Content Editor web part and add a link to this script file.
- Save the page(s) and test entering text into the multi-line text box.
/SiteAssets/JS/jquery-1.10.2.min.js
<script type="text/javascript"> $(function(){ $("textarea[title$='Description']").keyup(function(){ var txtValue = $("textarea[title$='Description']").text(); if(txtValue.length > 200){ alert("Your message..."); $("textarea[title$='Description']").val(txtValue.substring(0,199)); } }); }); </script>