<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Curtis Weir, Author at DMC, Inc.</title>
	<atom:link href="https://static.dmcinfo.com/blog/author/curtisw/feed/index.xml" rel="self" type="application/rss+xml" />
	<link></link>
	<description></description>
	<lastBuildDate>Fri, 24 Jul 2026 16:31:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://static.dmcinfo.com/wp-content/uploads/2025/04/site-icon-150x150.png</url>
	<title>Curtis Weir, Author at DMC, Inc.</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Connect a SharePoint Online Provider-Hosted App to Azure SQL Server (Part 2)</title>
		<link>https://static.dmcinfo.com/blog/20356/how-to-connect-a-sharepoint-online-provider-hosted-app-to-azure-sql-server-part-2/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Mon, 20 Jan 2020 11:57:12 +0000</pubDate>
				<category><![CDATA[Digital Workplace Solutions]]></category>
		<category><![CDATA[SharePoint]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/20356/how-to-connect-a-sharepoint-online-provider-hosted-app-to-azure-sql-server-part-2/</guid>

					<description><![CDATA[<p>This is the second part in a series for creating an app capable of utilizing data on both SharePoint and Azure. This guide will walk you through creating a simple application that will store data on Azure SQL Server and where users will interface with the app on a SharePoint page. The result will be [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/20356/how-to-connect-a-sharepoint-online-provider-hosted-app-to-azure-sql-server-part-2/">How to Connect a SharePoint Online Provider-Hosted App to Azure SQL Server (Part 2)</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This is the second part in a series for creating an app capable of utilizing data on both SharePoint and Azure. This guide will walk you through creating a simple application that will store data on Azure SQL Server and where users will interface with the app on a SharePoint page. The result will be a functional vacation request form.</p>



<p class="wp-block-paragraph">Before starting this tutorial, please refer to my<a href="https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/"> previous blog </a>to setup the connection between SharePoint and Azure by creating a Provider-hosted app.</p>



<h2 class="wp-block-heading" id="h-requirements">Requirements</h2>



<ul class="wp-block-list">
<li><a href="https://azure.microsoft.com/en-us/free/?v=17.39&amp;WT.srch=1&amp;WT.mc_id=AID631184_SEM_IznH9RWC&amp;lnkd=Google_Azure_Brand&amp;gclid=Cj0KCQiAwKvTBRC2ARIsAL0Dgk373lRtJFu8RUuPNw6i5fA_EROWyilrtvQbpxXW22eliZ5bjxtqCw4aApBfEALw_wcB">Microsoft Azure Subscription</a></li>



<li>Office 365 Tenant</li>



<li>SharePoint Online Site</li>



<li><a href="https://docs.microsoft.com/en-us/sharepoint/use-app-catalog?redirectSourcePath=%252fen-us%252farticle%252fUse-the-App-Catalog-to-make-custom-business-apps-available-for-your-SharePoint-Online-environment-0b6ab336-8b83-423f-a06b-bcc52861cba0">SharePoint Online App Catalog</a></li>



<li>Visual Studio (2015 used in this tutorial)</li>



<li>SQL Server Management Studio</li>
</ul>



<h2 class="wp-block-heading" id="h-create-an-nbsp-azure-sql-server-database">Create an&nbsp;Azure SQL Server Database</h2>



<p class="wp-block-paragraph">When creating a new application, I typically start with the model. To create a new SQL Server Database, perform the following steps:</p>



<ol class="wp-block-list">
<li>Navigate to the <a href="https://login.microsoftonline.com/common/oauth2/authorize?resource=https%3a%2f%2fmanagement.core.windows.net%2f&amp;response_mode=form_post&amp;response_type=code+id_token&amp;scope=user_impersonation+openid&amp;state=OpenIdConnect.AuthenticationProperties%3d3gkweM22gFqyBzjrg0t1XYA23dw3GADjR1vGPOTQsm1iFYQz9rdjJK5hgbwG9KNcU6IZrI09cKdHR0tURjwUtoB5MRx_uhenkpGSc5KQCVcIx0xFlWLhx4mxT7114b_wlp0kn5vcAH2IApAQXzYjEsvHe_lyrToYBrClECWPSvjtaxcuL6ZffDOCweJitprt0b-CQ9oNHMxiUEROVnjAOzg7YYOO9nIj76hVFzyEiCN4G4CNBK3YuLKnnd042z_iLazR4DmWoVAJ0fF3mxTi5pZ7qNjwSm630HwkspENUwavtP_jR6vGwYD4EX7QtI6joUHB7iWcQZGQjw0LI4coHphYpwLztZ37R-Fa7k8Ou0u8SAUSAtEka9KP6hBQSqC1ZOj1MlbRodG1pmjijELJ1w&amp;nonce=637151385029252947.ODMzYjg1ZmQtZTg4OC00YTZhLTgyYzktODA4ZTk0ZjcwODBhYmNlZWZmMDktOGU3YS00Y2U4LWIyZDItNTZkYjQwMTMyMjRk&amp;client_id=c44b4083-3bb0-49c1-b47d-974e53cbdf3c&amp;redirect_uri=https%3a%2f%2fportal.azure.com%2fsignin%2findex%2f%3ffeature.refreshtokenbinding%3dtrue%26feature.snivalidation%3dtrue%26feature.usemsallogin%3dfalse&amp;site_id=501430&amp;client-request-id=6c97b799-f3fe-4c9f-88e3-1879c195b283&amp;x-client-SKU=ID_NET&amp;x-client-ver=1.0.40306.1554">Azure portal</a>.</li>



<li>Click Create a <strong>resource &#8211;&gt; databases &#8211;&gt; SQL Databases.</strong></li>



<li>Complete the form and click <strong>Create</strong>. Your SQL Database will now be provisioned in the background.</li>
</ol>



<p class="wp-block-paragraph">If you have any questions about the setup options, refer to the <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-single-database-get-started?tabs=azure-portal">OuickStart tutorial</a>.</p>



<h2 class="wp-block-heading" id="h-connect-to-the-azure-sql-database">Connect to the Azure SQL Database</h2>



<p class="wp-block-paragraph">The next step in our model creation process is to connect to our new database. Perform the following to connect to the database:</p>



<ol class="wp-block-list">
<li>&nbsp;Launch <strong>SQL Server Management Studio (SSMS)</strong></li>



<li>Server type: <strong>Database Engine</strong></li>



<li>Server name: <strong>YourServerName.database.windows.net</strong></li>



<li>Authentication: SQL Server Authentication</li>



<li>Provide the admin username and password associated with the SQL server specified in the previous section.</li>



<li>Click <strong>Connect</strong></li>
</ol>



<p class="wp-block-paragraph">If you receive the message<strong> “Cannot open server ‘xxxxxxxx’ requested by the login. Client with IP address &#8216;xxx.xxx.xxx.xxx&#8217; is not allowed to access the server”</strong> follow these steps:</p>



<ol class="wp-block-list">
<li>On the<strong> Azure portal,</strong> navigate to the <strong>specified SQL Server</strong></li>



<li>Under <strong>Security</strong>, click <strong>Firewalls </strong>and V<strong>irtual Networks</strong></li>



<li>Add a <strong>new rule </strong>with the <strong>IP address from the error message</strong></li>



<li>Click <strong>Save</strong></li>



<li>Attempt to connect to the server again through SSMS</li>
</ol>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="900" height="746" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/PHA_Diagram_2_1.png" alt="PHA Diagram 2 1" class="wp-image-20350" srcset="https://static.dmcinfo.com/wp-content/uploads/2025/05/PHA_Diagram_2_1.png 900w, https://static.dmcinfo.com/wp-content/uploads/2025/05/PHA_Diagram_2_1-300x249.png 300w, https://static.dmcinfo.com/wp-content/uploads/2025/05/PHA_Diagram_2_1-768x637.png 768w" sizes="(max-width: 900px) 100vw, 900px" /></figure>



<p class="wp-block-paragraph">Upon connecting to your SQL Server, you should first create a user that will be used by our Provider-Hosted App.</p>



<ol class="wp-block-list">
<li>In the <strong>Object Explorer</strong>, first expand the SQL Server and then expand Security</li>



<li>Right-click <strong>Logins </strong>and select <strong>New Login&#8230;</strong></li>



<li>On the new window, replace the text with:
 <pre class="sql"><use><span style="color:#0000ff;">	USE </span>[ma<span id="cke_bm_254C" style="display: none;">&nbsp;</span><span id="cke_bm_225C" style="display: none;">&nbsp;</span>ster]</use>
<use><span style="color:#0000ff;">	GO</span></use>
<use><span style="color:#0000ff;">	CREATE LOGIN </span>[vacationuser] <span style="color:#0000ff;">WITH PASSWORD = </span><span style="color:#ff0000;">'YourPasswordGoesHere' </span></use>
<use><span style="color:#0000ff;">	GO</span></use></pre>
 </li>



<li>Click <strong>Execute </strong>to run the command.</li>



<li>Ensure the message window displays <strong>Command(s) completed successfully.</strong></li>



<li>In the <strong>Object Explorer</strong>, expand the <strong>Databases </strong>folder.</li>



<li>Right click your database and select <strong>New Query.</strong></li>



<li>On the new window, replace the text with:
 <pre class="sql"><use><span style="color:#0000ff;">	CREATE USER </span>[vacationuser] <span style="color:#0000ff;"> FOR LOGIN </span> [vacationuser]</use>
<use><span style="color:#0000ff;">	GO </span></use>
<use><span style="color:#0000ff">	EXEC <span style="color:#990000;">sp_addrolemember </span><span style="color:#ff0000;">'db_datareader', 'vacationuser'</span></span></use>
<use><span style="color:#0000ff;">	GO </span></use>
<use><span style="color:#0000ff;">	EXEC </span><span style="color:#990000;">sp_addrolemember </span><span style="color:#ff0000;">'db_datawriter', 'vacationuser'</span></use>
<use><span style="color:#0000ff;">	GO </span></use></pre>
 </li>



<li>Click <strong>Execute </strong>to run the command.</li>



<li>Ensure the message window displays <strong>Command(s) completed successfully.</strong></li>
</ol>



<p class="wp-block-paragraph">Now we have a user with read and write access to our new database. Later we will configure our app to connect to this database by utilizing this login.</p>



<h2 class="wp-block-heading" id="h-create-the-vacation-request-table">Create the Vacation Request Table</h2>



<p class="wp-block-paragraph">Next, we will configure the table to hold our vacation requests. Similarly to the section above, we will use SSMS to create the table. If you’ve closed the window from the above step, right-click <strong>Your database</strong> and select <strong>New Query</strong>. Paste the following into the window:</p>


<pre class="sql">
<use><span style="color:#0000ff;">CREATE TABLE </span>[dbo].[VacationRequest]<span style="color:#aaaaaa;">( </span> 
		[id] [int] <span style="color:#0000ff;">IDENTITY</span>(1,1) <span style="color:#0000ff;">PRIMARY KEY </span><span style="color:#aaaaaa;">NOT NULL,</span> 
      	[username] [nvarchar]<span style="color:#aaaaaa;">(</span><span style="color:#ff00ff;">max</span><span style="color:#aaaaaa;">) NOT NULL, </span> 
        [startdate] [datetime]<span style:=""> NOT NULL,</span>
    	[enddate] [datetime] <span style:="">NOT NULL </span>
<span style:="">) </span>
<span style="color:#0000ff;">GO </span></use> </pre>


<p class="wp-block-paragraph">Click <strong>execute </strong>and verify the message <strong>Command(s) completed successfully</strong> is displayed. If you refresh the object explorer pane, you should see the below table definition:</p>



<p class="wp-block-paragraph"><b></b></p>



<h2 class="wp-block-heading" id="h-sharepoint-app-enhancements">SharePoint App Enhancements</h2>



<p class="wp-block-paragraph">In the <a href="https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/">previous tutorial</a> in this series, we created a simple ‘hello world’ app. We’ll now make improvements to create a user interface. The first step will be to set up our connection to the database (model).</p>



<ol class="wp-block-list">
<li>On the Web project, right-click the <strong>Models</strong> folder, and select <strong>Add &#8211;&gt;&nbsp;</strong><strong>New Item…</strong></li>



<li>Expand the <strong>Visual C#</strong> node, select the <strong>Data</strong> node, and choose <strong>ADO.NET Entity Data Model</strong>.</li>



<li>Give your model a name and click <strong>Add.</strong></li>



<li>Choose <strong>EF Designer from database</strong><em>&nbsp;&#8211;&gt;&nbsp;</em><strong>Next.</strong></li>



<li>Click <strong>New Connection…</strong></li>



<li>Select <strong>Microsoft SQL Server</strong>, then select <strong>Continue.</strong></li>



<li>Enter your server name <strong>mydb.database.windows.net.</strong></li>



<li>Set Authentication to <strong>SQL Server Authentication.</strong></li>



<li>Enter the credentials for the <strong>vacationuser</strong> we created earlier.</li>



<li>Check <strong>Save My Password.</strong></li>



<li>Click <strong>Test Connection</strong>, and verify <strong>Test Connection Succeeded</strong> is displayed.</li>



<li>Under <strong>Connect to a Database</strong>, select our <strong>Vacation Request</strong> database.</li>



<li>Click <strong>OK.</strong></li>



<li>Select <strong>Yes, include the sensitive data in the connection string.</strong></li>



<li>Click <strong>Next.</strong></li>



<li>Select your preferred entity framework version, then click <strong>Next.</strong></li>



<li>For <strong>Which database objects do you want to include in your model?</strong>, expand <strong>Tables</strong>, then <strong>dbo</strong>, and check for <strong>VacationRequest</strong>.</li>



<li>Click<strong> Finish.</strong></li>
</ol>



<p class="wp-block-paragraph">The next step is to setup our view with a form to submit vacation request data. To accomplish this, open the solution in<strong> Visual Studio</strong> and edit the file <strong>WebProject/Views/ClientWebPart1/Index.cshtml.</strong></p>



<p class="wp-block-paragraph">Replace the body content with:</p>


<pre class="html">
	<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">h2</span><span style="color:#0000ff;">&gt;</span>Vacation Request Form<span style="color:#0000ff;">&lt;/</span>h2<span style="color:#0000ff;">&gt;</span> 
	<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">form </span><span style="color:#ff0000;">method</span><span style="color:#0000ff;">=&quot;post&quot;&gt; </span>
		<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">label</span> <span style="color:#ff0000;">for</span><span style="color:#0000ff;">=&quot;startdate&quot;&gt;</span>Start Date<span style="color:#0000ff;">&lt;/</span><span style="color:#990000;">label</span><span style="color:#0000ff;">&gt;</span> 
		<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">input</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;date&quot;</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;StartDate&quot; /&gt;</span>
		<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">label</span> <span style="color:#ff0000;">for</span><span style="color:#0000ff;">=&quot;enddate&quot;&gt;</span>End Date<span style="color:#0000ff;">&lt;/</span><span style="color:#990000;">label</span><span style="color:#0000ff;">&gt;</span>
		<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">input </span><span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;date</span>&quot; name<span style="color:#0000ff;">=&quot;EndDate&quot; /&gt; </span><l><span style="color:#0000ff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</l>
		<span style="color:#0000ff;">&lt;</span><span style="color:#990000;">input </span><span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;submit&quot;</span> <span style="color:#ff0000;">value</span><span style="color:#0000ff;">=&quot;Submit&quot;/&gt; </span><l>&nbsp;&nbsp;&nbsp;</l>
	<span style="color:#0000ff;">&lt;/</span><span style="color:#990000;">form</span><span style="color:#0000ff;">&gt; </span></pre>


<p class="wp-block-paragraph">When the user hits submit, this will post the form to the web server. We can handle this request in the controller <strong>WebProject/Controllers/ClientWebPart1Controller.cs</strong>. Replace the file with the following:&nbsp;</p>


<pre class="csharp">
<span style="color:#0000ff;">using</span> Microsoft.SharePoint.Client;
<span style="color:#0000ff;">using</span> SharePointAddIn1Web.Models;
<span style="color:#0000ff;">using</span> System;
<span style="color:#0000ff;">using</span> System.Web.Mvc;

<span style="color:#0000ff;">namespace</span> SharePointAddIn1Web.Controllers
{
	<span style="color:#0000ff;">public class</span><span style="color:#66cccc;"> ClientWebPart1Controller</span> : Controller
	{
		<span style="color:#0000ff;">public</span> ActionResult Index()
		{
			<span style="color:#0000ff;">return</span> View();
		}
        
		[HttpPost]
		[SharePointContextFilter]
		<span style="color:#0000ff;">public</span> ActionResult Index(VacationRequest vacationRequest)
		{
			<span style="color:#0000ff;">user</span> spUser = <span style="color:#0000ff;">null</span>;
            
			<span style="color:#0000ff;">var</span> spContext = 
SharePointContextProvider.Current.GetSharePointContext(HttpContext);
        
			<span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> clientContext = spContext.CreateUserClientContextForSPHost())			{
				<span style="color:#0000ff;">if</span> (clientContext != <span style="color:#0000ff;">null</span>)
				{
					spUser = clientContext.Web.CurrectUser;
                    
					clientContext.Load(spUser, user =&gt; user.Title);
                    
					clientContext.ExecuteQuery();
				}
			}
			<span style="color:#0000ff;">using</span> (<span style="color:#0000ff;">var</span> vacationModel = <span style="color:#0000ff;">new</span> VacationRequestEntities())
			{
				vacationModel.VacationRequests.Add(<span style="color:#0000ff;">new</span> Models.VacationRequest
				{
					username = spUser.Title,
					startdate = vacationRequest.StartDate,
					enddate = vacatonRequest.Endate
				});
				vacationModel.SaveChanges();
			}
			<span style="color:#0000ff;">return</span> View();
		}
        
    }
        
	<span style="color:#0000ff;">public class</span> <span style="color:#66cccc;">VacationRequest </span>
	{
		<span style="color:#0000ff;">public</span> DateTime StartDate { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
		<span style="color:#0000ff;">public</span> DateTime EndDate { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
	}
} 
</pre>


<h2 class="wp-block-heading" id="h-get-the-publish-profile">Get the Publish Profile</h2>



<p class="wp-block-paragraph">After your new app has been provisioned, the next step is to obtain the publish profile. We will use this to deploy our web application changes.</p>



<p class="wp-block-paragraph"><u><strong>Select your newly created web app</strong></u></p>



<p class="wp-block-paragraph">In the Overview tab, click&nbsp;<strong>Get Publish Profile</strong>. This should download a <strong>.PublishSettings</strong> file to your computer.</p>



<p class="wp-block-paragraph"><b></b></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{204}" paraid="722543948"><strong><u>Deploy application&nbsp;</u></strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{208}" paraid="1271967289">Now that we’re finished coding our application, it’s time to deploy our web application to Azure. To accomplish this, perform the following:&nbsp;</p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{213}" paraid="532194263">Right-click<strong>&nbsp;SharePoint Add-in &#8211;&gt; Publish.</strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{219}" paraid="158477952">Click <strong>Deploy your web project.</strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{232}" paraid="2087619388">A dialog should open on the <strong>Preview tab</strong>. Change to the <strong>Connection tab</strong>&nbsp;and verify the connection works by clicking <strong>Validate Connection.</strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{232}" paraid="2087619388">Ensure the other data is entered correctly&nbsp;and&nbsp;click <strong>Publish.</strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{241}" paraid="966860992">The web project&nbsp;may&nbsp;take a few minutes to deploy. You should see details about the deployment progress in the&nbsp;output&nbsp;window.&nbsp;&nbsp;</p></p>



<p class="wp-block-paragraph"><p paraeid="{c1cd3bee-067f-4b74-a1d0-8c9d09120e40}{255}" paraid="2145610776"><strong><u>Application testing&nbsp;</u></strong></p></p>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{17}" paraid="2036191597">Now we can navigate back to the SharePoint page created in&nbsp;the&nbsp;previous tutorial.&nbsp;The UI should&nbsp;now display&nbsp;our form&nbsp;and look&nbsp;like&nbsp;this:</p></p>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{17}" paraid="2036191597"></p></p>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{26}" paraid="523781446">Enter a&nbsp;<strong>start and end date</strong>, then click&nbsp;<strong>submit</strong>.&nbsp;</p></p>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{37}" paraid="1288069088">Now, if we navigate back to SSMS, we can query the table for our new record. Right-click<strong> dbo.VacationRequest</strong>, then click <strong>Select Top 200 Rows.</strong> A new window should appear with the following:</p></p>



<h2 class="wp-block-heading" id="h-conclusion">Conclusion</h2>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{37}" paraid="1288069088"><b></b></p></p>



<p class="wp-block-paragraph"><p paraeid="{cec63261-11ef-4eee-90c8-3583f4386fb1}{48}" paraid="318707281">Our provider hosted app is now capable of writing&nbsp;to an Azure SQL Server Database.&nbsp;From here, you can create additional controllers, views, and webparts to extend the capabilities of your provider hosted app. Some examples could include adding a dashboard to display vacation requests, or you could establish an approval process for administrators to view and approve vacation requests.</p></p>



<p class="wp-block-paragraph">Find out more about DMC&#8217;s&nbsp;<a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint" target="_blank">SharePoint</a>&nbsp;and&nbsp;<a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services" target="_blank">Microsoft Consulting Services</a>.</p>
<p>The post <a href="https://static.dmcinfo.com/blog/20356/how-to-connect-a-sharepoint-online-provider-hosted-app-to-azure-sql-server-part-2/">How to Connect a SharePoint Online Provider-Hosted App to Azure SQL Server (Part 2)</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Create a SharePoint Online Provider-Hosted App</title>
		<link>https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Thu, 28 Dec 2017 07:40:39 +0000</pubDate>
				<category><![CDATA[Digital Workplace Solutions]]></category>
		<category><![CDATA[SharePoint]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/</guid>

					<description><![CDATA[<p>Provider-hosted apps allow us to run powerful processes and access data externally from SharePoint. This guide is intended to provide a clear, and easy-to-follow process for configuring an application that can utilize data from both SharePoint Online and Microsoft Azure. If you are unfamiliar with the differences between SharePoint-hosted and Provider-hosted add-ins, please read Microsoft&#8217;s [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/">How to Create a SharePoint Online Provider-Hosted App</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Provider-hosted apps allow us to run powerful processes and access data externally from SharePoint.</p>



<p class="wp-block-paragraph">This guide is intended to provide a clear, and easy-to-follow process for configuring an application that can utilize data from both SharePoint Online and Microsoft Azure.</p>



<p class="wp-block-paragraph">If you are unfamiliar with the differences between SharePoint-hosted and Provider-hosted add-ins, please read Microsoft&#8217;s guide on how to <a href="https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/choose-patterns-for-developing-and-hosting-your-sharepoint-add-in" target="_blank" rel="noreferrer noopener">choose a development pattern for your add-in</a>.</p>



<h2 id="h-requirements" class="wp-block-heading">Requirements</h2>



<ul class="wp-block-list">
<li><a href="https://azure.microsoft.com/en-us/free/?v=17.39&amp;WT.srch=1&amp;WT.mc_id=AID631184_SEM_IznH9RWC&amp;lnkd=Google_Azure_Brand&amp;gclid=Cj0KCQiAwKvTBRC2ARIsAL0Dgk373lRtJFu8RUuPNw6i5fA_EROWyilrtvQbpxXW22eliZ5bjxtqCw4aApBfEALw_wcB" target="_blank">Microsoft Azure Subscription</a></li>



<li>Office 365 Tenant</li>



<li>SharePoint Online Site</li>



<li><a href="https://support.office.com/en-us/article/Use-the-App-Catalog-to-make-custom-business-apps-available-for-your-SharePoint-Online-environment-0b6ab336-8b83-423f-a06b-bcc52861cba0" target="_blank">SharePoint Online App Catalog</a></li>



<li>Visual Studio (2015 used in this tutorial)</li>
</ul>



<h2 id="h-create-a-web-app-on-azure" class="wp-block-heading">Create a Web App on Azure</h2>



<ol class="wp-block-list">
<li>Go to <a href="https://portal.azure.com/#home" type="link" id="https://portal.azure.com/#home" target="_blank" rel="noreferrer noopener">Azure</a><br> &nbsp;</li>



<li>Select <strong>New</strong> &#8211;&gt; <strong>Web + Mobile</strong> &#8211;&gt; <strong>Web App</strong>.<br>
 &nbsp;</li>



<li>Fill out the new web app form and then click <strong>Create</strong>.<br>
 <br>
 
<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-WebApp_1.png" alt=""/></figure>
</li>
</ol>



<h2 id="h-get-the-publish-profile" class="wp-block-heading">Get the Publish Profile</h2>



<p class="wp-block-paragraph">After your new app has been provisioned, you will need to get the publish profile, which we will use at a later step.</p>



<ol class="wp-block-list">
<li>Select your newly created web app.<br>
 &nbsp;</li>



<li>In the Overview tab, click <strong>Get publish profile</strong>. This should download a <strong>.PublishSettings</strong> file to your computer.<br> <br>
<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-PublishProfileSmall_1.png" alt=""/></figure>
</li>
</ol>



<h2 id="h-register-the-app-on-sharepoint" class="wp-block-heading">Register the App on SharePoint</h2>



<p class="wp-block-paragraph">Follow the steps below to give our Azure-hosted app the credentials necessary to access information on SharePoint.</p>



<ol class="wp-block-list">
<li>Navigate to <strong>https://mysharepointsite.sharepoint.com/_layouts/15/appregnew.aspx</strong>.<br>  </li>



<li>Click <strong>Generate</strong> for both the Client Id and Client Secret fields.<br>
 &nbsp;</li>



<li>Enter a title for this app (ex. My Provider Hosted Add-in).<br>
 &nbsp;</li>



<li>For <strong>App Domain</strong>, enter your new Azure Web App URL excluding the &#8220;https://&/#8221;: <strong>mywebapp.azurewebsites.ne</strong> .<br>  </li>



<li>For <strong>Redirect URI</strong>, enter your new Azure Web App URL. <strong>https://mywebapp.azurewebsites.net/</strong> .<br>  </li>



<li>Click <strong>Create</strong>.<br>
 &nbsp;</li>



<li>Record the <strong>Client Id </strong>and <strong>Client Secret </strong>for use in a later step.<br>
 <br>
 
<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-Register.png" alt=""/></figure>
</li>
</ol>



<p class="wp-block-paragraph">You can view your registered apps at any time by navigating to <code>https://mysharepointsite.sharepoint.com/_layouts/15/AppPrincipals.aspx</code>.</p>



<h2 id="h-create-the-add-in-project" class="wp-block-heading">Create the Add-in Project</h2>



<p class="wp-block-paragraph">The next step is to write our app in Visual Studio.</p>



<p class="wp-block-paragraph">The following is a section of the Microsoft blog&nbsp;<a href="https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-started-creating-provider-hosted-sharepoint-add-ins" target="_blank">Get started creating provider-hosted SharePoint Add-ins</a> (For the web application type, I would suggest selecting an ASP.NET MVC Web Application as opposed to Web Forms):</p>



<ol class="wp-block-list">
<li>Start Visual Studio using the <strong>Run as administrator</strong> option.<br>
 &nbsp;</li>



<li>In Visual Studio, choose <strong>File</strong>&nbsp;&#8211;&gt; <strong>New</strong>&nbsp;&#8211;&gt; <strong>Project</strong>.<br>
 &nbsp;</li>



<li>In the <strong>New Project</strong> dialog box, expand the <strong>Visual C#</strong> node, expand the <strong>Office/SharePoint</strong> node, and then choose <strong>Add-ins</strong>&nbsp;&#8211;&gt; <strong>SharePoint Add-in</strong>.<br>
 &nbsp;</li>



<li>Name the project SampleAddIn, and then choose <strong>OK</strong>.<br>
 &nbsp;</li>



<li>In the first <strong>Specify the SharePoint Add-in Settings</strong> dialog box, do the following:
 
 
<ul class="wp-block-list" style="list-style-type: circle;">
  

<li>Provide the <strong>full URL </strong>of the SharePoint site that you want to use to debug your add-in. This is the URL of the Developer Site.<br />
  &nbsp;</li>


  

<li>Use <strong>HTTPS</strong>, not HTTP in the URL. At some point during this procedure, or shortly after it completes, you will be prompted to log in to this site. The timing of the prompt varies.<br />
  &nbsp;</li>


  

<li>Use the <strong>administrator credentials</strong>&nbsp;(in the *.onmicrosoft.com domain) that you created when you signed up for your Developer Site. For example, MyName@contoso.onmicrosoft.com.<br />
  &nbsp;</li>


  

<li>Under <strong>How do you want to host your SharePoint Add-in</strong>, choose <strong>Provider-hosted</strong>.<br />
  &nbsp;</li>


  

<li>Choose <strong>Next</strong>.<br />
  &nbsp;</li>


 </ul>
</li>



<li>On the <strong>Specify the target SharePoint version</strong> page, choose <strong>SharePoint Online</strong> and then choose <strong>Next</strong>.<br>
 &nbsp;</li>



<li>Under <strong>Which type of web application project do you want to create?</strong>, select&nbsp;<strong>ASP.NET Web Forms Application </strong>(I suggest choosing ASP.NET MVC Web Application here).<br>
 &nbsp;</li>



<li><span id="cke_bm_255C" style="display: none;">&nbsp;</span>Choose <strong>Next</strong>.<br>
 &nbsp;</li>



<li>Under <strong>How do you want your add-in to authenticate?</strong>, choose <strong>Use Windows Azure Access Control Service</strong>.<br>
 &nbsp;</li>



<li>In the wizard, choose <strong>Finish</strong>.</li>
</ol>



<p class="wp-block-paragraph">Much of the configuration is done when the solution opens. Two projects are created in the Visual Studio solution &#8211; one for the SharePoint Add-in and the other for the ASP.NET web application.</p>



<h2 id="h-add-a-web-part" class="wp-block-heading">Add a Web Part</h2>



<p class="wp-block-paragraph">After our new solution has been created, we need to add and configure a new web part. This will allow us to add and display an add-in on a SharePoint page.</p>



<ol class="wp-block-list">
<li>Right-click the <strong>SharePoint Add-in </strong>&#8211;&gt; <strong>Add </strong>&#8211;&gt; <strong>New Item&#8230;</strong><br>
 &nbsp;</li>



<li>In the <strong>New Project</strong> dialog box, expand the <strong>Visual C#&nbsp;</strong>node, expand the <strong>Office/SharePoint&nbsp;</strong>node, and then choose <strong>Client Web Part (Host Web)</strong>.<br>
 &nbsp;</li>



<li>Choose to <strong>Create a new web page for the client web part content </strong>and&nbsp;then name your new controller/view.<br>
 &nbsp;</li>



<li>Click <strong>Finish</strong>.<br>
 <br>
 We should now add some content to the new web part<br>
 &nbsp;</li>



<li>In the web app project, navigate to your new client web part view (<strong>WebProject/Views/ClientWebPart1/Index.cshtml</strong>).<br>  </li>



<li>Add <strong>&lt;h1>;Hello world!&lt;/h1></strong> within the body tag. This will simply be used to verify that our add-in can be displayed correctly on a SharePoint page.<br> <br>
<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-ProjectConfig_1.png" alt=""/></figure>
</li>
</ol>



<h2 id="h-publish-the-app" class="wp-block-heading">Publish the App</h2>



<p class="wp-block-paragraph">Now we can publish our new app. There are two parts to this. One step will push the web project to Azure, and the other will be packaged and added to our SharePoint app catalog.</p>



<p class="wp-block-paragraph"><strong><u>Deploy Your Web Project</u></strong></p>



<ol class="wp-block-list">
<li>Right-click the <strong>SharePoint Add-in </strong>&#8211;&gt; <strong>Publish&#8230;</strong><br>
 &nbsp;</li>



<li>Under <strong>Publish</strong>, select the caret next to <strong>Current profile</strong>, then select <strong>&lt;New&#8230;&gt;</strong>.<br>
 &nbsp;</li>



<li>Import your Publish profile by browsing to the file downloaded in the <strong>Get Publishing Profile</strong> step and click <strong>Next</strong>.<br>
 &nbsp;</li>



<li>For the <strong>Client ID </strong>and <strong>Secret</strong>, enter the values we recorded after performing the step <strong>Register the App on SharePoint</strong>.<br>
 &nbsp;</li>



<li>Click <strong>Finish</strong>. The new profile should now be selected on the publish screen.<br>
 &nbsp;</li>



<li>Click <strong>Deploy your web project</strong>.<br>
 &nbsp;</li>



<li>A dialog should open on the <strong>Preview</strong> tab. Change to the <strong>Connection</strong> tab, and verify the connection works by clicking <strong>Validate Connection</strong>.<br>
 &nbsp;</li>



<li>Ensure the other data is entered correctly, then click <strong>Publish</strong>.</li>
</ol>



<p class="wp-block-paragraph">The web project will take a few minutes to deploy. You should see details about the deployment progress in the Output.</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-WebPublish.png" alt=""/></figure>



<p class="wp-block-paragraph"><strong><u>Package the Add-In</u></strong></p>



<ol class="wp-block-list">
<li>On the <strong>Publish you add-in </strong>screen, click <strong>Package the add-in</strong>.<br>
 &nbsp;</li>



<li>For <strong>Where is your website hosted</strong>, enter your Azure site URL: <strong>https://mywebapp.azurewebsites.net/</strong> . (Important: needs to be set to HTTPS, <em>not </em>HTTP).<br>  </li>



<li>For <strong>What is the app&#8217;s Client ID</strong>, enter the value we recorded after performing the step <strong>Register the App on SharePoint</strong>.<br>
 &nbsp;</li>



<li>Click <strong>Finish</strong>. A .app file should be downloaded to your computer. The output window will show the saved location. Record this location for a later step.<br>
 &nbsp;</li>



<li>Navigate to your SharePoint app catalog (if you do not have an app catalog setup, please follow the link in the requirements).<br>
 &nbsp;</li>



<li>Go to Apps for SharePoint: <strong>/AppCatalog/Forms/AllItems.aspx</strong><br>  </li>



<li>Click <strong>Upload</strong>, then navigate to the .app file created in step 4.<br>
 &nbsp;</li>



<li>Click <strong>OK</strong>. Your app should then be deployed. Wait a minute then refresh the page.<br>
 &nbsp;</li>



<li>Verify the app now appears in the app catalog (the <strong>Deployed </strong>field should be set to <strong>Yes</strong>, and the <strong>App Package Error Message</strong> should be set to <strong>No errors</strong>).<br>
 <br>
 
<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-AppPublish.png" alt=""/></figure>
</li>
</ol>



<h2 id="h-add-the-app-to-sharepoint" class="wp-block-heading">Add the App to SharePoint</h2>



<p class="wp-block-paragraph">Our new app can now be added to the SharePoint site where it was registered.</p>



<ol class="wp-block-list">
<li>Navigate to that site and add a new app. The app we created should be in the <strong>Apps you can add</strong> list.<br>
 &nbsp;</li>



<li>After selecting the app, a dialog will appear asking you to trust the app. Click <strong>Trust It</strong>, and then the app will now be added to the site.<br>
 &nbsp;</li>



<li>Go to any page on the site and edit the page.<br>
 &nbsp;</li>



<li>Click <strong>Insert</strong> on the ribbon, then <strong>App Part</strong>.<br>
 ​​​​​​​</li>



<li>You should see our client web part on this list. Add the web part and save the page.</li>
</ol>



<p class="wp-block-paragraph">You should now see <strong>Hello world!</strong>.</p>



<p class="wp-block-paragraph">(Note: During my testing, I strangely got a server error on load. If this happens, republish the web app and try again)</p>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Curtis-ProviderHostedApp-Blog-NewPage.png" alt=""/></figure>



<h2 id="h-conclusion" class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">Congrats! You have now created a SharePoint Online Provider-hosted App. If you have any questions, please comment below.</p>



<p class="wp-block-paragraph">The next steps are to create a rich web app that is capable of consuming data from both SharePoint and external sources, such as a SQL database.</p>



<p class="wp-block-paragraph">This will be part of my next tutorial in this series.</p>



<p class="wp-block-paragraph">Find out more about DMC&#8217;s <a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint" target="_blank">SharePoint</a> and&nbsp;<a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services" target="_blank">Microsoft Consulting Services</a>.</p>
<p>The post <a href="https://static.dmcinfo.com/blog/23589/how-to-create-a-sharepoint-online-provider-hosted-app/">How to Create a SharePoint Online Provider-Hosted App</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Upload a File to SharePoint On-Premises Using Python</title>
		<link>https://static.dmcinfo.com/blog/24542/how-to-upload-a-file-to-sharepoint-on-premises-using-python/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Thu, 09 Mar 2017 12:12:06 +0000</pubDate>
				<category><![CDATA[Digital Workplace Solutions]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Custom SharePoint]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/24542/how-to-upload-a-file-to-sharepoint-on-premises-using-python/</guid>

					<description><![CDATA[<p>There are several tools out there for interacting with SharePoint through a Python script, but today, I am going to demonstrate a very simple way to upload a file to your SharePoint environment&#160;with minimal overhead. This can be useful for users running on Linux environments, such as&#160;a Raspberry PI, who want to script some functionality. [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/24542/how-to-upload-a-file-to-sharepoint-on-premises-using-python/">How to Upload a File to SharePoint On-Premises Using Python</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">There are several tools out there for interacting with SharePoint through a Python script, but today, I am going to demonstrate a very simple way to upload a file to your SharePoint environment&nbsp;with minimal overhead. This can be useful for users running on Linux environments, such as&nbsp;a Raspberry PI, who want to script some functionality.</p>



<h2 class="wp-block-heading" id="h-using-octoprint-to-monitor-3d-printing">Using Octoprint to Monitor 3D Printing</h2>



<p class="wp-block-paragraph">I recently set up a tool called <a href="http://octoprint.org/" target="_blank">Octoprint</a>&nbsp;on a Raspberry Pi, and am using it to control and monitor the 3D printer here at DMC.</p>



<p class="wp-block-paragraph">The tool generates timelapses after each print, and it started to take up a lot of space on the Pi’s storage.</p>



<p class="wp-block-paragraph"><iframe allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/Ndu9Qaakv44" width="560"></iframe></p>



<p class="wp-block-paragraph">I used the following script to take newly rendered timelapses and upload them to SharePoint. This allows users to easily access their print timelapses&nbsp;and frees space on the pi.</p>



<h2 class="wp-block-heading" id="h-setup">Setup</h2>



<p class="wp-block-paragraph">You will need to install the requests package and NTLM authentication package on your environment. In a Linux environment, type the following commands:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">Python</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>pip install requests

pip install requests_ntlm</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #D4D4D4">pip install requests</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">pip install requests_ntlm</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-python-script">Python Script</h2>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">Python</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>#Import required packages
import sys
import requests
from requests_ntlm import HttpNtlmAuth

#Read filename (relative path) from command line
fileName = sys.argv&#91;1&#93;

#Enter your SharePoint site and target library
sharePointUrl = 'https://your.sharepointsite.com/'
folderUrl = '/Your/SharePoint/DocumentLibrary'

#Sets up the url for requesting a file upload
requestUrl = sharePointUrl + '/_api/web/getfolderbyserverrelativeurl(\'' + folderUrl + '\')/Files/add(url=\'' + fileName + '\',overwrite=true)'

#Read in the file that we are going to upload
file = open(fileName, 'rb')

#Setup the required headers for communicating with SharePoint 
headers = {'Content-Type': 'application/json; odata=verbose', 'accept': 'application/json;odata=verbose'}

#Execute a request to get the FormDigestValue. This will be used to authenticate our upload request
r = requests.post(sharePointUrl + "/_api/contextinfo",auth=HttpNtlmAuth('Domain\\username','password'), headers=headers)
formDigestValue = r.json()&#91;'d'&#93;&#91;'GetContextWebInformation'&#93;&#91;'FormDigestValue'&#93;

#Update headers to use the newly acquired FormDigestValue
headers = {'Content-Type': 'application/json; odata=verbose', 'accept': 'application/json;odata=verbose', 'x-requestdigest' : formDigestValue}

#Execute the request. If you run into issues, inspect the contents of uploadResult
uploadResult = requests.post(requestUrl,auth=HttpNtlmAuth('Domain\\username','password'), headers=headers, data=file.read())</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">#Import required packages</span></span>
<span class="line"><span style="color: #C586C0">import</span><span style="color: #D4D4D4"> sys</span></span>
<span class="line"><span style="color: #C586C0">import</span><span style="color: #D4D4D4"> requests</span></span>
<span class="line"><span style="color: #C586C0">from</span><span style="color: #D4D4D4"> requests_ntlm </span><span style="color: #C586C0">import</span><span style="color: #D4D4D4"> HttpNtlmAuth</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Read filename (relative path) from command line</span></span>
<span class="line"><span style="color: #D4D4D4">fileName = sys.argv&#91;</span><span style="color: #B5CEA8">1</span><span style="color: #D4D4D4">&#93;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Enter your SharePoint site and target library</span></span>
<span class="line"><span style="color: #D4D4D4">sharePointUrl = </span><span style="color: #CE9178">&apos;https://your.sharepointsite.com&/#39;</span></span>
<span class="line"><span style="color: #D4D4D4">folderUrl = </span><span style="color: #CE9178">&apos;/Your/SharePoint/DocumentLibrary&apos;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Sets up the url for requesting a file upload</span></span>
<span class="line"><span style="color: #D4D4D4">requestUrl = sharePointUrl + </span><span style="color: #CE9178">&apos;/_api/web/getfolderbyserverrelativeurl(</span><span style="color: #D7BA7D">\&apos;</span><span style="color: #CE9178">&apos;</span><span style="color: #D4D4D4"> + folderUrl + </span><span style="color: #CE9178">&apos;</span><span style="color: #D7BA7D">\&apos;</span><span style="color: #CE9178">)/Files/add(url=</span><span style="color: #D7BA7D">\&apos;</span><span style="color: #CE9178">&apos;</span><span style="color: #D4D4D4"> + fileName + </span><span style="color: #CE9178">&apos;</span><span style="color: #D7BA7D">\&apos;</span><span style="color: #CE9178">,overwrite=true)&apos;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Read in the file that we are going to upload</span></span>
<span class="line"><span style="color: #D4D4D4">file = </span><span style="color: #DCDCAA">open</span><span style="color: #D4D4D4">(fileName, </span><span style="color: #CE9178">&apos;rb&apos;</span><span style="color: #D4D4D4">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Setup the required headers for communicating with SharePoint </span></span>
<span class="line"><span style="color: #D4D4D4">headers = {</span><span style="color: #CE9178">&apos;Content-Type&apos;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&apos;application/json; odata=verbose&apos;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&apos;accept&apos;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&apos;application/json;odata=verbose&apos;</span><span style="color: #D4D4D4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Execute a request to get the FormDigestValue. This will be used to authenticate our upload request</span></span>
<span class="line"><span style="color: #D4D4D4">r = requests.post(sharePointUrl + </span><span style="color: #CE9178">&quot;/_api/contextinfo&quot;</span><span style="color: #D4D4D4">,</span><span style="color: #9CDCFE">auth</span><span style="color: #D4D4D4">=HttpNtlmAuth(</span><span style="color: #CE9178">&apos;Domain</span><span style="color: #D7BA7D">\\</span><span style="color: #CE9178">username&apos;</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&apos;password&apos;</span><span style="color: #D4D4D4">), </span><span style="color: #9CDCFE">headers</span><span style="color: #D4D4D4">=headers)</span></span>
<span class="line"><span style="color: #D4D4D4">formDigestValue = r.json()&#91;</span><span style="color: #CE9178">&apos;d&apos;</span><span style="color: #D4D4D4">&#93;&#91;</span><span style="color: #CE9178">&apos;GetContextWebInformation&apos;</span><span style="color: #D4D4D4">&#93;&#91;</span><span style="color: #CE9178">&apos;FormDigestValue&apos;</span><span style="color: #D4D4D4">&#93;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Update headers to use the newly acquired FormDigestValue</span></span>
<span class="line"><span style="color: #D4D4D4">headers = {</span><span style="color: #CE9178">&apos;Content-Type&apos;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&apos;application/json; odata=verbose&apos;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&apos;accept&apos;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&apos;application/json;odata=verbose&apos;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&apos;x-requestdigest&apos;</span><span style="color: #D4D4D4"> : formDigestValue}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">#Execute the request. If you run into issues, inspect the contents of uploadResult</span></span>
<span class="line"><span style="color: #D4D4D4">uploadResult = requests.post(requestUrl,</span><span style="color: #9CDCFE">auth</span><span style="color: #D4D4D4">=HttpNtlmAuth(</span><span style="color: #CE9178">&apos;Domain</span><span style="color: #D7BA7D">\\</span><span style="color: #CE9178">username&apos;</span><span style="color: #D4D4D4">,</span><span style="color: #CE9178">&apos;password&apos;</span><span style="color: #D4D4D4">), </span><span style="color: #9CDCFE">headers</span><span style="color: #D4D4D4">=headers, </span><span style="color: #9CDCFE">data</span><span style="color: #D4D4D4">=file.read())</span></span></code></pre></div>



<p class="wp-block-paragraph">Browse to your SharePoint site, and you should now see the newly uploaded file.</p>



<p class="wp-block-paragraph">Learn more about DMC&#8217;s&nbsp;<a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint">SharePoint Consulting Services</a>&nbsp;and&nbsp;<a href="https://static.dmcinfo.com/services/digital-workplace-solutions">Digital Workplace Solutions</a>&nbsp;team.&nbsp;<a href="https://static.dmcinfo.com/contact">Contact us</a>&nbsp;for your next custom SharePoint project.</p>
<p>The post <a href="https://static.dmcinfo.com/blog/24542/how-to-upload-a-file-to-sharepoint-on-premises-using-python/">How to Upload a File to SharePoint On-Premises Using Python</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SharePoint Form Validation Using JavaScript + jQuery</title>
		<link>https://static.dmcinfo.com/blog/25245/sharepoint-form-validation-using-javascript-jquery/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Tue, 30 Aug 2016 16:18:04 +0000</pubDate>
				<category><![CDATA[Digital Workplace Solutions]]></category>
		<category><![CDATA[SharePoint]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25245/sharepoint-form-validation-using-javascript-jquery/</guid>

					<description><![CDATA[<p>SharePoint forms are usually very simple in terms of validation. The only out-of-the-box feature is to make a field required. While this is useful, sometimes businesses want more control over what users should&#160;and should not enter into a form. Fortunately, it is easy to write our own code to extend the validation of a SharePoint [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25245/sharepoint-form-validation-using-javascript-jquery/">SharePoint Form Validation Using JavaScript + jQuery</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">SharePoint forms are usually very simple in terms of validation. The only out-of-the-box feature is to make a field required. While this is useful, sometimes businesses want more control over what users should&nbsp;and should not enter into a form. Fortunately, it is easy to write our own code to extend the validation of a SharePoint form.</p>



<h2 class="wp-block-heading" id="h-sharepoint-form-background">SharePoint Form Background</h2>



<p class="wp-block-paragraph">When the save button is pressed on a SharePoint form, the PreSaveItem function is called. That function is as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">JavaScript</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function PreSaveItem() {
	a: ;return "function" == typeof PreSaveAction ? PreSaveAction() : true
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #569CD6">function</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">PreSaveItem</span><span style="color: #D4D4D4">() {</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #C8C8C8">a</span><span style="color: #D4D4D4">: ;</span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #CE9178">&quot;function&quot;</span><span style="color: #D4D4D4"> == </span><span style="color: #569CD6">typeof</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">PreSaveAction</span><span style="color: #D4D4D4"> ? </span><span style="color: #DCDCAA">PreSaveAction</span><span style="color: #D4D4D4">() : </span><span style="color: #569CD6">true</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<p class="wp-block-paragraph">This code will return the result of PreSaveAction (if it is defined). Thus, writing our own function called PreSaveAction will cause SharePoint to run our code (when the user attempts to save a form). We will return &#8220;true&#8221; in this new function to approve the form for submission, or &#8220;false&#8221; if we discover any errors.</p>



<h2 class="wp-block-heading" id="h-example-code">Example Code</h2>



<p class="wp-block-paragraph">The example code below is a template you can use and customize for your own needs.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">JavaScript</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>//When the user clicks 'Save', SharePoint will run this function
function PreSaveAction(){
	//Returning true will cause the form to be submitted, false will prevent form submission
	var result = true;
	
	//Clear out existing error messages
	$('.errorMessage').remove();
	
	//Select the input of a text field
	var textField = GetFieldByDisplayName("Example Text Field");
	
	//Check if the input is empty
	if (textField &amp;&amp; !textField.val().trim()){
		result = false;
		//Write a message indicating to the user that the field is empty
		WriteErrorMessage(textField, "You can''t leave this blank.");
	}
	
	//Select the textarea of a multi-line text field
	var multiLineTextField = GetFieldByDisplayName("Example Multi Line Text Field");
	
	//Check if textarea contains invalid characters
	if (multiLineTextField.val() &amp;&amp; /^&#91;a-zA-Z0-9- &#93;*$/.test(multiLineTextField.val().trim() == false){
		result = false;
		//Write a message indicating to the user that the field contains a invalid characters
		WriteErrorMessage(textField, "You cannot use special characters in this field.");
	}
	
	var dateField = GetFieldByDisplayName("Example Date Field");
	if (dateField){
		//Get date object from input value
		var dateFieldValue = new Date(dateField.val());
		
		//Check if date input is invalid
		if (isNaN(dateFieldValue.getDate())){
			result = false;
			WriteErrorMessage(dateField, "Invalid date.");
		}
		
		//Check if date field is in the future
		if (dateFieldValue &amp;&amp; dateFieldValue > new Date()){
			result = false;
			WriteErrorMessage(dateField, "You cannot select a future date.");
		}
	}
	return result;
}

//Append an error message to a field       
function WriteErrorMessage(inputElement, message){
	var errorMessageMarkup = '&lt;span class="errorMessage ms-formvalidation ms-csrformvalidation">&lt;span role="alert">' + message + '&lt;br>&lt;/span>';
	$(inputElement).parent().append(errorMessageMarkup);
}

//Gets a jQuery object that represents a field element
function GetFieldByDisplayName(fieldName){
	var field = $('input&#91;title="' + fieldName + '"&#93;, &#91;title="' + fieldName + ' Required Field"&#93;');
	if (!field){
		field = $('textarea&#91;title="' + fieldName + '"&#93;, &#91;title="' + fieldName + ' Required Field"&#93;');
	}
	return field;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #6A9955">//When the user clicks &apos;Save&apos;, SharePoint will run this function</span></span>
<span class="line"><span style="color: #569CD6">function</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">PreSaveAction</span><span style="color: #D4D4D4">(){</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Returning true will cause the form to be submitted, false will prevent form submission</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">true</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Clear out existing error messages</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&apos;.errorMessage&apos;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">remove</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Select the input of a text field</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">textField</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">GetFieldByDisplayName</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Example Text Field&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Check if the input is empty</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">textField</span><span style="color: #D4D4D4"> &amp;&amp; !</span><span style="color: #9CDCFE">textField</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">val</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">trim</span><span style="color: #D4D4D4">()){</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Write a message indicating to the user that the field is empty</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #DCDCAA">WriteErrorMessage</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">textField</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;You can&apos;&apos;t leave this blank.&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	}</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Select the textarea of a multi-line text field</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">multiLineTextField</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">GetFieldByDisplayName</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Example Multi Line Text Field&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #6A9955">//Check if textarea contains invalid characters</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">multiLineTextField</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">val</span><span style="color: #D4D4D4">() &amp;&amp;</span><span style="color: #D16969"> /</span><span style="color: #DCDCAA">^</span><span style="color: #CE9178">&#91;</span><span style="color: #D16969">a-zA-Z0-9- </span><span style="color: #CE9178">&#93;</span><span style="color: #D7BA7D">*</span><span style="color: #DCDCAA">$</span><span style="color: #D16969">/</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">test</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">multiLineTextField</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">val</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">trim</span><span style="color: #D4D4D4">() == </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">){</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Write a message indicating to the user that the field contains a invalid characters</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #DCDCAA">WriteErrorMessage</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">textField</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;You cannot use special characters in this field.&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	}</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #9CDCFE">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">dateField</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">GetFieldByDisplayName</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Example Date Field&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #DCDCAA">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">dateField</span><span style="color: #D4D4D4">){</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Get date object from input value</span></span>
<span class="line"><span style="color: #D4D4D4">		var </span><span style="color: #9CDCFE">dateFieldValue</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">new</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">Date</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">dateField</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">val</span><span style="color: #D4D4D4">());</span></span>
<span class="line"><span style="color: #D4D4D4">		</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Check if date input is invalid</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #DCDCAA">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">isNaN</span><span style="color: #D4D4D4">(dateFieldValue.getDate())){</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #DCDCAA">WriteErrorMessage</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">dateField</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;Invalid date.&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">		}</span></span>
<span class="line"><span style="color: #D4D4D4">		</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Check if date field is in the future</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #DCDCAA">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">dateFieldValue</span><span style="color: #D4D4D4"> &amp;&amp; </span><span style="color: #9CDCFE">dateFieldValue</span><span style="color: #D4D4D4"> &gt; </span><span style="color: #9CDCFE">new</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">Date</span><span style="color: #D4D4D4">()){</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4"> = </span><span style="color: #569CD6">false</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #DCDCAA">WriteErrorMessage</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">dateField</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;You cannot select a future date.&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">		}</span></span>
<span class="line"><span style="color: #D4D4D4">	}</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #9CDCFE">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">result</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">//Append an error message to a field       </span></span>
<span class="line"><span style="color: #569CD6">function</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">WriteErrorMessage</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">inputElement</span><span style="color: #D4D4D4">, </span><span style="color: #9CDCFE">message</span><span style="color: #D4D4D4">){</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">errorMessageMarkup</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&apos;&lt;span class=&quot;errorMessage ms-formvalidation ms-csrformvalidation&quot;&gt;&lt;span role=&quot;alert&quot;&gt;&apos;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">message</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&apos;&lt;br&gt;&lt;/span&gt;&apos;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">inputElement</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">parent</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">append</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">errorMessageMarkup</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #6A9955">//Gets a jQuery object that represents a field element</span></span>
<span class="line"><span style="color: #569CD6">function</span><span style="color: #D4D4D4"> </span><span style="color: #DCDCAA">GetFieldByDisplayName</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">fieldName</span><span style="color: #D4D4D4">){</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&apos;input&#91;title=&quot;&apos;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">fieldName</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&apos;&quot;&#93;, &#91;title=&quot;&apos;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">fieldName</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&apos; Required Field&quot;&#93;&apos;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (!</span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4">){</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&apos;textarea&#91;title=&quot;&apos;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">fieldName</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&apos;&quot;&#93;, &#91;title=&quot;&apos;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">fieldName</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&apos; Required Field&quot;&#93;&apos;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	}</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #C586C0">return</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="h-deployment">Deployment</h2>



<p class="wp-block-paragraph">For steps on attaching our custom code to a form, please refer to my<a href="https://static.dmcinfo.com/latest-thinking/blog/id/9160/how-to-hide-fields-on-a-sharepoint-form"> SharePoint Javascript tutorial</a>.</p>



<p class="wp-block-paragraph"><strong><a href="https://static.dmcinfo.com/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint">Learn more about DMC&#8217;s SharePoint services.</a></strong></p>



<p class="wp-block-paragraph"></p>
<p>The post <a href="https://static.dmcinfo.com/blog/25245/sharepoint-form-validation-using-javascript-jquery/">SharePoint Form Validation Using JavaScript + jQuery</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Hide Fields on a SharePoint Form</title>
		<link>https://static.dmcinfo.com/blog/25912/how-to-hide-fields-on-a-sharepoint-form/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Tue, 02 Feb 2016 12:23:02 +0000</pubDate>
				<category><![CDATA[Digital Workplace Solutions]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Scripting]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/25912/how-to-hide-fields-on-a-sharepoint-form/</guid>

					<description><![CDATA[<p>Hiding fields in a SharePoint form can be tedious, or sometimes not even possible using out-of-the-box features. One common solution is to modify the forms in SharePoint Designer. However, this takes time and is prone to user error. A simpler solution is to use Javascript &amp; jQuery, and the following code outlines how to hide [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25912/how-to-hide-fields-on-a-sharepoint-form/">How to Hide Fields on a SharePoint Form</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Hiding fields in a SharePoint form can be tedious, or sometimes not even possible using out-of-the-box features. One common solution is to modify the forms in SharePoint Designer. However, this takes time and is prone to user error.</p>



<p class="wp-block-paragraph">A simpler solution is to use Javascript &amp; jQuery, and the following code outlines how to hide any field on your SharePoint form. If you are unfamiliar with Javascript, no problem! Just edit the <em>fieldsToHide</em> line with whatever fields you wish to hide. Separate fields using commas, and surround each field with quotations.</p>



<p class="wp-block-paragraph">If you would like to understand how the code works in detail, read the following section. If not, skip to Adding the Code to Your SharePoint Site.</p>



<h2 class="wp-block-heading" id="h-the-code">The Code</h2>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:16px 0 0 16px;width:100%;text-align:left;background-color:#1e1e1e"><span style="background:#c7c7c7;padding:0.3rem 0.5rem 0.2rem;border-radius:1rem;font-size:0.8em;line-height:1;height:1.25rem;text-align:center;display:inline-flex;align-items:center;justify-content:center;color:#1e1e1e">JavaScript</span></span><span role="button" tabindex="0" style="color:#D4D4D4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;script src="//code.jquery.com/jquery-latest.min.js">&lt;/script>
&lt;script>
	function HideFields() {
		//Enter the fields you would like to hide here.
		fieldsToHide = &#91;"Enter", "Field Names", "Here"&#93;;
	
		//Get all SharePoint fields
		var formFieldTitles = $(".ms-formtable td.ms-formlabel h3.ms-standardheader");

		//Iterate over each row in the form
		formFieldTitles.each(function () {
			//Get the text of the field title
			var textToMatch = $(this).text();
			//Get the table row associated with this title
			var currentRow = $(this).closest('tr');

			//Iterate over our list of fields we wish to hide
			for (var i = 0; i &lt; fieldsToHide.length; i++){
				var field = fieldsToHide&#91;i&#93;;
				//Match the SharePoint field name to our field name
				if (textToMatch.toLowerCase().replace("*", "").trim() === field.toLowerCase().replace("*", "").trim()){
					//Hide this field
					$(currentRow).hide();
				}
			}
		});
	}

	function AddToBodyOnLoad(){
		//Ensure that our function is called last by pushing it again
		_spBodyOnLoadFunctionNames.push("HideFields");
	}

	//Add our function to the array of onload functions
	_spBodyOnLoadFunctionNames.push("AddToBodyOnLoad");
&lt;/script></textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki dark-plus" style="background-color: #1E1E1E" tabindex="0"><code><span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">script</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">src</span><span style="color: #D4D4D4">=</span><span style="color: #CE9178">&quot;//code.jquery.com/jquery-latest.min.js&quot;</span><span style="color: #808080">&gt;&lt;/</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #808080">&lt;</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">	function HideFields() </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Enter the fields you would like to hide here.</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">fieldsToHide</span><span style="color: #D4D4D4"> = &#91;</span><span style="color: #CE9178">&quot;Enter&quot;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;Field Names&quot;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;Here&quot;</span><span style="color: #D4D4D4">&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">	</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Get all SharePoint fields</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">formFieldTitles</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;.ms-formtable td.ms-formlabel h3.ms-standardheader&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Iterate over each row in the form</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">formFieldTitles</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">each</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">function</span><span style="color: #D4D4D4"> () {</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #6A9955">//Get the text of the field title</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">textToMatch</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">text</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #6A9955">//Get the table row associated with this title</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">currentRow</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #569CD6">this</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">closest</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&apos;tr&apos;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #6A9955">//Iterate over our list of fields we wish to hide</span></span>
<span class="line"><span style="color: #D4D4D4">			</span><span style="color: #C586C0">for</span><span style="color: #D4D4D4"> (</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">i</span><span style="color: #D4D4D4"> = </span><span style="color: #B5CEA8">0</span><span style="color: #D4D4D4">; </span><span style="color: #9CDCFE">i</span><span style="color: #D4D4D4"> &lt; </span><span style="color: #9CDCFE">fieldsToHide</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">length</span><span style="color: #D4D4D4">; </span><span style="color: #9CDCFE">i</span><span style="color: #D4D4D4">++){</span></span>
<span class="line"><span style="color: #D4D4D4">				</span><span style="color: #569CD6">var</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4"> = </span><span style="color: #9CDCFE">fieldsToHide</span><span style="color: #D4D4D4">&#91;</span><span style="color: #9CDCFE">i</span><span style="color: #D4D4D4">&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">				</span><span style="color: #6A9955">//Match the SharePoint field name to our field name</span></span>
<span class="line"><span style="color: #D4D4D4">				</span><span style="color: #C586C0">if</span><span style="color: #D4D4D4"> (</span><span style="color: #9CDCFE">textToMatch</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">toLowerCase</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">replace</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;*&quot;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">trim</span><span style="color: #D4D4D4">() === </span><span style="color: #9CDCFE">field</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">toLowerCase</span><span style="color: #D4D4D4">().</span><span style="color: #DCDCAA">replace</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;*&quot;</span><span style="color: #D4D4D4">, </span><span style="color: #CE9178">&quot;&quot;</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">trim</span><span style="color: #D4D4D4">()){</span></span>
<span class="line"><span style="color: #D4D4D4">					</span><span style="color: #6A9955">//Hide this field</span></span>
<span class="line"><span style="color: #D4D4D4">					</span><span style="color: #DCDCAA">$</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">currentRow</span><span style="color: #D4D4D4">).</span><span style="color: #DCDCAA">hide</span><span style="color: #D4D4D4">();</span></span>
<span class="line"><span style="color: #D4D4D4">				}</span></span>
<span class="line"><span style="color: #D4D4D4">			}</span></span>
<span class="line"><span style="color: #D4D4D4">		});</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">	function AddToBodyOnLoad()</span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #6A9955">//Ensure that our function is called last by pushing it again</span></span>
<span class="line"><span style="color: #D4D4D4">		</span><span style="color: #9CDCFE">_spBodyOnLoadFunctionNames</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">push</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;HideFields&quot;</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">	</span><span style="color: #569CD6">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">	//Add our function to the array of onload functions</span></span>
<span class="line"><span style="color: #D4D4D4">	_spBodyOnLoadFunctionNames.push(&quot;AddToBodyOnLoad&quot;);</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">script</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<p class="wp-block-paragraph">The first line imports the jQuery library, which makes it easier to select and hide elements on a page. To learn more about jQuery, visit <a href="https://jquery.com/" target="_blank">their official website</a>.</p>



<p class="wp-block-paragraph">The first line in <em>HideFields()</em> defines which fields we are going to hide. This is the line that you should change to match the fields on your form, and add additional fields if desired.</p>



<p class="wp-block-paragraph">The <em>AddToBodyOnLoad()</em> function forces our function to be loaded last on the page. This ensures that the fields have been created and are viewable in the DOM.</p>



<p class="wp-block-paragraph">The <em>HideFields()</em> function iterates over each field on the form, then iterates over each field in our list of fields we want to hide. If there’s a match, the entire row is hidden from view. Unfortunately, we cannot remove this row from the DOM, since there will be unintended side-effects, and SharePoint will not be able to save the list item.</p>



<h2 class="wp-block-heading" id="h-adding-the-code-to-your-sharepoint-site">Adding the Code to Your SharePoint Site</h2>



<h3 class="wp-block-heading" id="h-sharepoint-2013-amp-office-365">SharePoint 2013 &amp; Office 365</h3>



<ol class="wp-block-list">
<li>Navigate to your SharePoint list.</li>



<li>In your browser url, replace <em>AllItems.aspx</em> with the name of the form (default forms are NewForm.aspx, EditForm.aspx, and DispForm.aspx).</li>



<li>Click the Gear icon in the top right, then “Edit Page”.</li>



<li>Click “Add a Web Part”.</li>



<li>Under “Categories”, select “Media and Content”.</li>



<li>Under “Parts”, select “Script Editor”.</li>



<li>On the new Web part, click “Edit Snippet”.</li>



<li>Copy the code from above, and paste the contents into the dialog.</li>



<li>Edit the 5<sup>th</sup> line with the fields you want to hide on this form.</li>



<li>Click “Insert”.</li>



<li>In the top left, click “Page”, then “Stop Editing”.</li>



<li>Your fields should now be hidden from view.</li>
</ol>



<h3 class="wp-block-heading" id="h-sharepoint-2010">SharePoint 2010</h3>



<ol class="wp-block-list">
<li>Navigate to your SharePoint list.</li>



<li>In your browser URL, replace <em>AllItems.aspx</em> with the name of the form (default forms are NewForm.aspx, EditForm.aspx, and DispForm.aspx).</li>



<li>Click the “Site Actions” in the top left, then “Edit Page”.</li>



<li>Click “Add a Web Part”.</li>



<li>Under “Categories”, select “Media and Content”.</li>



<li>Under “Parts”, select “Content Editor”.</li>



<li>On the new Web part, click “Click here to add new content”.</li>



<li>In the “Editing Tools” ribbon section, click “Format Text”.</li>



<li>In the “Markup” section, click “HTML”, then click “Edit HTML Source”.</li>



<li>Copy the code from above, and paste the contents into the dialog.</li>



<li>Edit the 5<sup>th</sup> line with the fields you want to hide on this form.</li>



<li>Click “OK”.</li>



<li>In the top left, click “Page”, then “Stop Editing”.</li>



<li>Your fields should now be hidden from view.</li>
</ol>



<p class="wp-block-paragraph"><a href="/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint">Learn more about DMC&#8217;s SharePoint services.</a></p>



<p class="wp-block-paragraph"><a href="/contact">Contact us</a> for <a href="/services/digital-workplace-solutions/microsoft-consulting-services/sharepoint">SharePoint</a> consulting.</p>
<p>The post <a href="https://static.dmcinfo.com/blog/25912/how-to-hide-fields-on-a-sharepoint-form/">How to Hide Fields on a SharePoint Form</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Beer on a Boat: Exactly as Fun as it Sounds</title>
		<link>https://static.dmcinfo.com/blog/26424/beer-on-a-boat-exactly-as-fun-as-it-sounds/</link>
		
		<dc:creator><![CDATA[Curtis Weir]]></dc:creator>
		<pubDate>Fri, 07 Aug 2015 13:15:09 +0000</pubDate>
				<category><![CDATA[Chicago]]></category>
		<category><![CDATA[Culture]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/26424/beer-on-a-boat-exactly-as-fun-as-it-sounds/</guid>

					<description><![CDATA[<p>After being in Chicago for over four years, I realized that I had never been on a boat tour down the Chicago River. So coming up with the idea was relatively easy. I noticed that many people at DMC enjoy beer, and boating ventures are very popular in the summer, so a booze cruise seemed [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/26424/beer-on-a-boat-exactly-as-fun-as-it-sounds/">Beer on a Boat: Exactly as Fun as it Sounds</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="wp-block-paragraph">After being in Chicago for over four years, I realized that I had never been on a boat tour down the Chicago River. So coming up with the idea was relatively easy. I noticed that many people at DMC enjoy beer, and boating ventures are very popular in the summer, so a booze cruise seemed like an ideal welcoming party.</p>

<p class="wp-block-paragraph">The week leading up to the event was pretty stormy, so I was afraid the boat ride would be either miserable or cancelled altogether. Luckily, the evening was perfect! The ride started at 7pm as the sun was setting. This provided the perfect setting for the Instagram aficionado: sun shining between the skyscrapers and glistening off the water.</p>

<figure class="wp-block-image"><img decoding="async" alt="beer-on-a-boat-sunset" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/pic_cropped.jpg"  /></figure>

<p class="wp-block-paragraph">As we were setting off, I noticed many new faces in our group. Since there was a management meeting the next day, many of the higher-ups from the other offices around the country were present! It was great to get to meet and converse with so many coworkers that I do not get to interact with on a daily basis.</p>

<p class="wp-block-paragraph">We started the voyage listening to a very detailed tour guide who explained all of the buildings we passed. I distinctly remember being amazed at all the buildings that were literally built on top of existing ones. After about an hour or so of travelling up and down the river, we ventured out onto Lake Michigan. I noticed a few in our group were standing at the front of the boat, so I joined them in recreating <a href="http://i.imgur.com/WCNxZ.gif" target="_blank">everyone&rsquo;s favorite Titanic scene</a>. The rest of the group slowly started to gather, and pretty soon everyone was at the front! &nbsp;The queue to enter and leave the channel was fairly long, so we actually got a free hour on the boat from waiting (I&rsquo;m not complaining).</p>

<p class="wp-block-paragraph">Throughout the evening, I felt so welcomed by everyone I spoke to. Everyone was friendly and I received quite a few comments on how much they were enjoying themselves.&nbsp; This experience was by far the most fun I have had thus far at a DMC event. The setting, the drinks, the sense of community, and the bartender&rsquo;s glorious mustache made this a night I will always remember.</p>

<figure class="wp-block-image"><img decoding="async" alt="DMC on Lake Michigan" class="MobileImage" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/IMG_00591.jpg"  /></figure>

<figure class="wp-block-image"><img decoding="async" alt="DMC on Lake Michigan" class="MobileImage" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/IMG_01061.jpg"  /></figure>
<p class="wp-block-paragraph"><a href="/about">Learn more about DMC&apos;s company culture.</a></p>
<p>The post <a href="https://static.dmcinfo.com/blog/26424/beer-on-a-boat-exactly-as-fun-as-it-sounds/">Beer on a Boat: Exactly as Fun as it Sounds</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
