<?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>JavaScript Archives | DMC, Inc.</title>
	<atom:link href="https://static.dmcinfo.com/blog/tag/javascript/feed/index.xml" rel="self" type="application/rss+xml" />
	<link></link>
	<description></description>
	<lastBuildDate>Fri, 04 Sep 2026 14:37:31 +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>JavaScript Archives | DMC, Inc.</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Electrifying Desktop Application Development with Electron</title>
		<link>https://static.dmcinfo.com/blog/15849/electrifying-desktop-application-development-with-electron/</link>
		
		<dc:creator><![CDATA[DMC]]></dc:creator>
		<pubDate>Mon, 18 Nov 2024 10:58:38 +0000</pubDate>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[PC Application Development]]></category>
		<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[Electron]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/15849/electrifying-desktop-application-development-with-electron/</guid>

					<description><![CDATA[<p>You&#8217;ve already used an Electron application.&#160;So, what is Electron? You’ve already used an Electron application; you just might not have known it. Electron applications provide the basis for some of the apps you use daily—Microsoft Teams, Slack, and Visual Studio Code. Electron is a modern, open-source framework for building desktop applications. Since it runs on [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/15849/electrifying-desktop-application-development-with-electron/">Electrifying Desktop Application Development with Electron</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 id="h-you-ve-already-used-an-electron-application-nbsp-so-what-is-electron" class="wp-block-heading">You&#8217;ve already used an Electron application.&nbsp;So, what is Electron?</h2>



<p class="wp-block-paragraph">You’ve already used an Electron application; you just might not have known it. Electron applications provide the basis for some of the apps you use daily—Microsoft Teams, Slack, and Visual Studio Code.</p>



<p class="wp-block-paragraph"><a href="https://www.electronjs.org/" target="_blank" rel="noreferrer noopener">Electron</a> is a modern, open-source framework for building desktop applications. Since it runs on the Node.js runtime, Electron makes it possible to harness JavaScript—typically a web technology—for the development of desktop applications. That’s a powerful way to take our expertise in web technology and apply it to desktop development.</p>



<p class="wp-block-paragraph">Let’s talk about why DMC loves building with Electron!</p>



<h2 id="h-why-dmc-develops-with-electron" class="wp-block-heading">Why DMC develops with Electron</h2>



<p class="wp-block-paragraph"><strong>Electron is cross-platform.</strong> Have a use case that calls for compatibility with Windows, macOS, and Linux? Your Electron application will run on all three, so you need just one code base. You’ll benefit from a smaller, tighter engineering team focused on a single application for minimized time to market and maximized market reach across multiple platforms. A singular code base means that bug fixes, updates, and new features need only be implemented once.</p>



<p class="wp-block-paragraph"><strong>Built on the Node.js runtime.</strong> Equally as important is the runtime itself. Electron runs on Node.js, a JavaScript runtime environment, taking advantage of JavaScript’s position as the<a href="https://survey.stackoverflow.co/2023/#technology-most-popular-technologies"> world’s eminent web technology</a>. Not only does this align with DMC’s sweeping base of expertise in developing JavaScript-based applications, but it also means that you’ll be able to involve your developers in the technical process during an application’s development and support, including post-handoff of the application. That common technical understanding means all parties are speaking the same language and are geared up for success for the lifetime of the application.</p>



<p class="wp-block-paragraph"><strong>Prototyping and proof-of-concepting. </strong>An often-understated utility of Electron development is its handiness for prototyping. Since Electron applications can be spun up quickly — and because you&#8217;ll have access to the vast community of established libraries and frameworks built for JavaScript — an Electron application is ideally suited to building out a viable proof of concept perfect for getting projects off to a promising start.</p>



<p class="wp-block-paragraph"><strong>Trying out new ideas with Electron Fiddle.</strong> Sometimes, all you need is a playground to test out that idea that’s been bouncing around in your head. Electron Fiddle is Electron’s take on <a href="https://jsfiddle.net/">JSFiddle</a>. It’s a lightweight desktop studio for quickly running a simple Electron project. Maybe you want to experiment with a new feature for your application. Or maybe you want to download someone else’s demo and click around on your own. Fiddle allows you&nbsp;to run an Electron application without the overhead of initializing a completely new project. I love this capability and use it both for exploring new features and testing out small tweaks to colleagues’ code. You can read up on <a href="https://www.electronjs.org/fiddle">Electron Fiddle</a> here.</p>



<p class="wp-block-paragraph"><strong>Packaging and Distributing with Electron Forge. </strong>Electron Forge is the all-in-one tool for initiating, configuring, pipelining, and distributing an Electron application. At the start of your project, you’ll use the Electron Forge CLI to spin up a template application. Later, when it’s time to distribute, Electron Forge facilitates three core steps in the distribution sequence:</p>



<ol class="wp-block-list">
<li>The <em>packaging</em> of the application to a bundled executable</li>



<li>The <em>making</em> of the bundled executable into a distributable (such as a .zip or an .exe)</li>



<li>The <em>publishing</em> of the distributable so that your application is available for users to download</li>
</ol>



<h2 id="h-users-love-it" class="wp-block-heading">Users love it</h2>



<p class="wp-block-paragraph">Developing for the web means recognizing the dominant design for the everyday user’s experience. Developers and non-developers alike have come to expect a certain standard: a modern browser serving webpages on a modern JavaScript framework—think React with Material UI or Angular with Angular UI. Why shouldn’t this expectation carry over to the desktop application experience? For consistency and seamlessness, it makes sense to craft desktop applications that look and feel like their web counterparts.</p>



<p class="wp-block-paragraph">An Electron application fluently brings the desktop application must-haves—offline capabilities, local system access, process launching, hardware discovery—and merges them with the familiar user interface elements of the web.</p>



<p class="wp-block-paragraph">When it comes to picking JavaScript frameworks and libraries, Electron lets you choose your own tools. You can keep things simple and lean on basic HTML and CSS. Or you can scaffold up a full-fledged React application via Next.js.</p>



<h2 id="h-case-study-a-desktop-application-for-high-throughput-data-analysis-and-visualization" class="wp-block-heading">Case Study: A desktop application for high-throughput data analysis and visualization</h2>



<p class="wp-block-paragraph"><b>The problem: </b>Our client, a global aerospace and defense technology company, sought to modernize their in-house data analysis and visualization workflow. Their existing workflow relied on several de-coupled applications for processing and exhibiting their data, and there was no official means of warehousing the data. Their team needed a successor platform to provide stronger scalability and faster workflow throughput while still retaining the data reporting functionalities of the legacy system. In modernizing the legacy platform, they laid out a set of key requirements:</p>



<ul class="wp-block-list">
<li>The solution must provide for the storage of captured data.</li>



<li>The solution must ingest large datasets and visualize them clearly, and it must do so performantly.
 
 
<ul class="wp-block-list">
<li>Presentation of data must support advanced visualization controls such as time-shifting, zooming, and time-trending.</li>



<li>Plotting must be capable of processing up to 1 million data points.</li>
</ul>
</li>



<li>The solution must support the validation of data.</li>



<li>The solution’s data processing must be offline-capable. If data is available locally, no network connection shall be required for the core functionality of the application.</li>
</ul>



<p class="wp-block-paragraph"><strong>The solution:</strong> DMC identified a path forward to replace the legacy workflow platform with a single cohesive solution. The bedrock of the solution is a data analysis desktop application built on Electron. Here’s why we landed on Electron for building out this application:</p>



<ul class="wp-block-list">
<li>Electron gives our development team access to a range of powerful JavaScript packages for plotting, UI, and navigation. These are the packages that supply the familiar, expected experience of the web, and Electron brings them to the desktop environment.</li>



<li>Electron’s access to the native OS empowers us to launch a local Python service upon Electron startup. This allows us to easily take advantage of Python’s proven libraries for data crunching, validation, and report generation.</li>
</ul>



<p class="wp-block-paragraph">To round out the solution, we then spun up cloud-based data storage hosted on Amazon’s S3 service. As a whole, DMC delivered an application to meet the&nbsp;client&#8217;s need for a comprehensive data intelligence and reporting platform.</p>



<div class="wp-block-group alignwide has-custom-light-blue-background-color has-background is-layout-flow wp-container-core-group-is-layout-dbd34961 wp-block-group-is-layout-flow" style="border-radius:20px;margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--50);padding-right:0;padding-bottom:var(--wp--preset--spacing--50);padding-left:0">
<div class="wp-block-columns alignwide are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-43efaee5 wp-block-columns-is-layout-flex" style="padding-right:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:85%">
<h3 class="wp-block-heading has-text-align-left" id="h-have-an-upcoming-project-dmc-can-help-you-take-the-next-step"><strong>Bring Modern Web Experiences to the Desktop</strong></h3>



<p class="has-text-align-left wp-block-paragraph" id="h-need-help-turning-ideas-into-outcomes-automation-project-to-the-next-level-contact-us-today-to-learn-more-about-our-solutions-and-how-we-can-help-you-achieve-your-goals">Explore our <a href="https://static.dmcinfo.com/services/application-development/" data-type="page" data-id="434">Application Development</a> expertise in Electron, JavaScript, and cross-platform architectures for building scalable <a href="https://static.dmcinfo.com/services/application-development/desktop-application-development/" data-type="page" data-id="680">desktop applications</a> from a unified codebase.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<div class="wp-block-buttons is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-2236275c wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-fill"><a class="wp-block-button__link has-base-contrast-color has-text-color has-link-color wp-element-button" href="https://static.dmcinfo.com/contact/">Contact Us</a></div>
</div>
</div>
</div>
</div>
<p>The post <a href="https://static.dmcinfo.com/blog/15849/electrifying-desktop-application-development-with-electron/">Electrifying Desktop Application Development with Electron</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Basic JavaScript Localization Setup Using JSON with Visual Studio Code</title>
		<link>https://static.dmcinfo.com/blog/15997/basic-javascript-localization-setup-using-json-with-visual-studio-code/</link>
		
		<dc:creator><![CDATA[Shannon Coupland]]></dc:creator>
		<pubDate>Mon, 16 Sep 2024 12:55:30 +0000</pubDate>
				<category><![CDATA[Web Application Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<guid isPermaLink="false">https://static.dmcinfo.com/blog/15997/basic-javascript-localization-setup-using-json-with-visual-studio-code/</guid>

					<description><![CDATA[<p>Frontend localization is different than .NET backend localization in that there is not an established “correct way” to accomplish translating text in JS and related frameworks. This is a basic example using JavaScript, but more customization can be done with methods and helpers for accessing text, especially if you are using a JS framework like [&#8230;]</p>
<p>The post <a href="https://static.dmcinfo.com/blog/15997/basic-javascript-localization-setup-using-json-with-visual-studio-code/">Basic JavaScript Localization Setup Using JSON with Visual Studio Code</a> appeared first on <a href="https://static.dmcinfo.com/">DMC, Inc.</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Frontend localization is different than .NET backend localization in that there is not an established “correct way” to accomplish translating text in JS and related frameworks. This is a basic example using JavaScript, but more customization can be done with methods and helpers for accessing text, especially if you are using a JS framework like React or Material UI.</p>



<p class="wp-block-paragraph"><strong>Prerequisites</strong></p>



<ul class="wp-block-list">
<li>Visual Studio Code installed on your machine</li>



<li>Node.js version 20.17.0 installed on your machine (other versions of Node will likely work as well)</li>



<li>General understanding of navigation in Visual Studio Code IDE</li>
</ul>



<p class="wp-block-paragraph"><strong>Steps</strong></p>



<ol class="wp-block-list">
<li>Open Visual Studio Code and create an empty folder “LocalizationExampleJS”:<br>
 <br>
 <img decoding="async" alt="Open Visual Studio Code" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Localization-JavaScript-1.png"><br>
 &nbsp;</li>



<li value="2">Add the file &ldquo;LocalizationExample.js&rdquo; at the top level of your new folder:<br />
 <br />
 <img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Localization-JavaScript-2.png"  /><br />
 &nbsp;</li>



<li value="3">Add a new subfolder &quot;Resources&quot;&nbsp;with empty files &ldquo;en-US.json&rdquo;, &ldquo;es-MX.json&rdquo;, and &ldquo;fr-FR.json&rdquo;:<br />
 <br />
 <img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Localization-JavaScript-3.png"  /><br />
 <br />
 <img decoding="async" alt="" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Localization-JavaScript-4.png"  /></li>



<li>Add the following code to each JSON translation file. It’s important for the text keys in all 3 files to be identical – in this case, the sample text we are using has the key “HelloWorld”.</li>
</ol>



<p class="wp-block-paragraph"><code><strong>en-US.json</strong></code></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">JSON</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;code>
{
  "HelloWorld": "Hello World!"
}
es-MX.json
{
  "HelloWorld": "¡Hola Mundo!"
}
fr-FR.json
{
  "HelloWorld": "Bonjour le monde!"
}
&lt;/code></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">&lt;code&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">&quot;HelloWorld&quot;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&quot;Hello World!&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span>
<span class="line"><span style="color: #D4D4D4">es-MX.json</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">&quot;HelloWorld&quot;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&quot;¡Hola Mundo!&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span>
<span class="line"><span style="color: #D4D4D4">fr-FR.json</span></span>
<span class="line"><span style="color: #D4D4D4">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">&quot;HelloWorld&quot;</span><span style="color: #D4D4D4">: </span><span style="color: #CE9178">&quot;Bonjour le monde!&quot;</span></span>
<span class="line"><span style="color: #D4D4D4">}</span></span>
<span class="line"><span style="color: #D4D4D4">&lt;/code&gt;</span></span></code></pre></div>



<ol class="wp-block-list">
<li value="5">Add the following code to &ldquo;LocalizationExample.js&rdquo;. This will enable you to supply a command line argument containing your desired locale string during testing. (Note that in an actual web frontend solution, the frontend code would need to access the current user&rsquo;s culture from the server, NOT via command line argument.)</li>
</ol>



<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>&lt;code>
const args = process.argv.slice(2);
const currentCulture = args&#91;0&#93;;
console.log("Your supplied culture is: " + currentCulture);
&lt;/code></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">code</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">const args = process.argv.slice(2);</span></span>
<span class="line"><span style="color: #D4D4D4">const currentCulture = args&#91;0&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">console.log(&quot;Your supplied culture is: &quot; + currentCulture);</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">code</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<ol class="wp-block-list">
<li value="6">Below the code to extract current culture from command line arguments, add the following code to access the &ldquo;HelloWorld&rdquo; string for the supplied culture. If a culture is supplied that is not present in the application, then an error message will log accordingly, and the application will default to the &ldquo;en-US&rdquo; locale.</li>
</ol>



<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;code>
var pathToJson = "./Resources/" + args&#91;0&#93; + ".json";
try {
  const jsonObj = require(pathToJson);
  console.log(jsonObj.HelloWorld);
}
catch (err) {
  console.log("Culture \"" + currentCulture + "\" does not exist in this application - using default locale en-US.")
  pathToJson = "./Resources/en-US.json";
  const jsonObj = require(pathToJson);
  console.log(jsonObj.HelloWorld);
}
&lt;/code></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">code</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">var pathToJson = &quot;./Resources/&quot; + args&#91;0&#93; + &quot;.json&quot;;</span></span>
<span class="line"><span style="color: #D4D4D4">try </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">const</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">require</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">HelloWorld</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #569CD6">}</span></span>
<span class="line"><span style="color: #D4D4D4">catch (err) </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Culture </span><span style="color: #D7BA7D">\&quot;</span><span style="color: #CE9178">&quot;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">currentCulture</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&quot;</span><span style="color: #D7BA7D">\&quot;</span><span style="color: #CE9178"> does not exist in this application - using default locale en-US.&quot;</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;./Resources/en-US.json&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">const</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">require</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">HelloWorld</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #569CD6">}</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">code</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<ol class="wp-block-list">
<li value="7">Your code is ready for testing! It should look something like this:</li>
</ol>



<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;code>
const args = process.argv.slice(2);
const currentCulture = args&#91;0&#93;;
console.log("Your supplied culture is: " + currentCulture);

var pathToJson = "./Resources/" + args&#91;0&#93; + ".json";
try {
  const jsonObj = require(pathToJson);
  console.log(jsonObj.HelloWorld);
}
catch (err) {
  console.log("Culture \"" + currentCulture + "\" does not exist in this application - using default locale en-US.")
  pathToJson = "./Resources/en-US.json";
  const jsonObj = require(pathToJson);
  console.log(jsonObj.HelloWorld);
}
&lt;/code></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">code</span><span style="color: #808080">&gt;</span></span>
<span class="line"><span style="color: #D4D4D4">const args = process.argv.slice(2);</span></span>
<span class="line"><span style="color: #D4D4D4">const currentCulture = args&#91;0&#93;;</span></span>
<span class="line"><span style="color: #D4D4D4">console.log(&quot;Your supplied culture is: &quot; + currentCulture);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D4D4D4">var pathToJson = &quot;./Resources/&quot; + args&#91;0&#93; + &quot;.json&quot;;</span></span>
<span class="line"><span style="color: #D4D4D4">try </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">const</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">require</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">HelloWorld</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #569CD6">}</span></span>
<span class="line"><span style="color: #D4D4D4">catch (err) </span><span style="color: #569CD6">{</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #CE9178">&quot;Culture </span><span style="color: #D7BA7D">\&quot;</span><span style="color: #CE9178">&quot;</span><span style="color: #D4D4D4"> + </span><span style="color: #9CDCFE">currentCulture</span><span style="color: #D4D4D4"> + </span><span style="color: #CE9178">&quot;</span><span style="color: #D7BA7D">\&quot;</span><span style="color: #CE9178"> does not exist in this application - using default locale en-US.&quot;</span><span style="color: #D4D4D4">)</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4"> = </span><span style="color: #CE9178">&quot;./Resources/en-US.json&quot;</span><span style="color: #D4D4D4">;</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">const</span><span style="color: #D4D4D4"> </span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4"> = </span><span style="color: #DCDCAA">require</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">pathToJson</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #D4D4D4">  </span><span style="color: #9CDCFE">console</span><span style="color: #D4D4D4">.</span><span style="color: #DCDCAA">log</span><span style="color: #D4D4D4">(</span><span style="color: #9CDCFE">jsonObj</span><span style="color: #D4D4D4">.</span><span style="color: #9CDCFE">HelloWorld</span><span style="color: #D4D4D4">);</span></span>
<span class="line"><span style="color: #569CD6">}</span></span>
<span class="line"><span style="color: #808080">&lt;/</span><span style="color: #569CD6">code</span><span style="color: #808080">&gt;</span></span></code></pre></div>



<ol class="wp-block-list">
<li value="8">Open a terminal and test out the LocalizationExample solution using the command node <strong><code>.\LocalizationExample.js</code></strong> xx-XX, where &ldquo;xx-XX&rdquo; is a locale string representing the combination of a language and a region. Try out &ldquo;es-MX&rdquo;, &ldquo;fr-FR&rdquo;, &ldquo;en-US&rdquo;, and &ldquo;pt-BR&rdquo; (Brazilian Portuguese) as command line arguments.<br />
 <br />
 Note that the HelloWorld resource for the cultures &ldquo;en-US&rdquo;, &ldquo;es-MX&rdquo;, and &ldquo;fr-FR&rdquo; all appear translated as expected. However, the &ldquo;pt-BR&rdquo; locale yields the HelloWorld string in English, because this culture is not present in the collection of translations, and our code explicitly defaults to the &ldquo;en-US&rdquo; U.S. English locale in this case.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://static.dmcinfo.com/wp-content/uploads/2025/05/Localization-JavaScript-6.png" alt=""/></figure>



<h2 id="h-localization-tips-and-tricks" class="wp-block-heading"><strong>Localization Tips and Tricks</strong></h2>



<p class="wp-block-paragraph">When it comes to localization, there is a lot more to consider than simply translating text and accessing it appropriately from code. Read on to learn some tips and tricks for elevating your localization solution!</p>



<p class="wp-block-paragraph"><strong>Text Key Organization</strong></p>



<p class="wp-block-paragraph">Generally, DMC has found that it is beneficial to organize text keys into separate files based not only on language, but also based on what page of your application the text belongs on. For backend localization, this is likely best done by splitting text by controller. Here is an example of a backend localization file structure that includes two controllers, “Login.cs” and “Home.cs”, and two cultures, a default culture and “es-MX”:</p>



<ul class="wp-block-list">
<li>Resources folder
 
 
<ul class="wp-block-list" style="list-style-type:circle;">
  

<li>Login folder
  

<ul class="wp-block-list">
   

<li>Login.resx</li>


   

<li>Login.es-MX.resx</li>


  </ul>


  </li>


  

<li>Home folder
  

<ul class="wp-block-list">
   

<li>Home.resx</li>


   

<li>Home.es-MX.resx</li>


  </ul>


  </li>


 </ul>
</li>
</ul>



<p class="wp-block-paragraph">This separation organizes your translated text in a way that is easily modifiable for each individual page of your application.</p>



<p class="wp-block-paragraph">In the event that identical text appears in multiple places in your application in English, it is still beneficial to duplicate that text key/value entry across pages, rather than maintaining a single key/value item. For example, if the word “Email” exists on both the “Login” and “Home” pages in the example above, this text key/value should exist in both the “Login” resource files and “Home” resource files. This enables you to update the text in one place without modifying the same text elsewhere, if desired. Also, translations of the same English word or phrase could be different across different languages, depending on the context of how the word or phrase is used – in this case, separate text/key values are necessary for translators to appropriately translate your application text.</p>



<p class="wp-block-paragraph"><strong>Variables and Pluralization</strong></p>



<p class="wp-block-paragraph">Variables and pluralization can be quite tricky to handle in any localization solution. For a backend solution with .resx files, if you have a sentence to translate with a variable in the middle, you need to separate any given string key/value into separate parts that precede and follow the variable.</p>



<p class="wp-block-paragraph">For example, say you want to include the phrase “Hello, {name} – welcome to my site!” The following key/value structure would need to be implemented in each .resx file to handle this phrase:</p>


<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="width:319px;">


<p class="wp-block-paragraph"><strong>Key</strong></p>


</td>
<td style="width:319px;">


<p class="wp-block-paragraph"><strong>Value (en-US)</strong></p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“Hello, “</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“ – welcome to my site!”</p>


</td>
</tr>
</tbody>
</table>


<p class="wp-block-paragraph">&nbsp;</p>



<p class="wp-block-paragraph">Additionally, numeric variables add an extra layer of complexity to a localization solution, because pluralization must be implemented for these. The way words are pluralized can actually differ significantly across languages. For example, Slavic languages (e.g. Russian, Czech) have a different style of pluralization for 5 or more of an item than they do for zero, one, or 2-4 items. So a solution that translates to Slavic languages must implement separate logic for pluralizing 5+ items than for other items. For example, the sentence “You have {number} items in your cart!” may have a key/value structure like this in English:</p>


<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="width:319px;">


<p class="wp-block-paragraph"><strong>Key</strong></p>


</td>
<td style="width:319px;">


<p class="wp-block-paragraph"><strong>Value (en-US)</strong></p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“You have “</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“ items in your cart!”</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“You have “</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“ item in your cart!”</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“You have “</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“ items in your cart!”</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“You have “</p>



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


</td>
<td style="width:319px;">


<p class="wp-block-paragraph">“ items in your cart!”</p>


</td>
</tr>
</tbody>
</table>


<p class="wp-block-paragraph">As you can see, this is a complex case to translate for – there are 8 total key/value pairs to accommodate just one sentence that integrates a numeric variable. To avoid the need for this, one solution is to reduce or eliminate the need for accommodating plurals – for example, you could rephrase “You have {number} items in your cart!” to instead become “Number of Items in Cart: {number}”. This would only require one key/value pair to be translated instead of eight.</p>



<p class="wp-block-paragraph"><strong>Fallback Cultures</strong></p>



<p class="wp-block-paragraph">When a user’s specific locale does not have a translation present in your application, it can be beneficial to implement fallback cultures so this user is given a more suitable approximation of their desired language. For example, say a Spanish speaker lives in Spain and therefore has their browser locale set to “es-ES”. However, your application only has resources for Mexican Spanish “es-MX”. Ideally this person in Spain would see the application in Mexican Spanish rather than the application default of English, because Mexican Spanish more closely matches their desired language than English does.</p>



<p class="wp-block-paragraph">Using .NET backend localization, fallback cultures can be implemented by simply renaming any files ending in “es-MX.resx” to instead end in “es.resx”. Per .NET’s <a href="#culture-fallback-scenarios">culture fallback scenarios</a>, upon receiving a request from the Spain Spanish user, .NET will still search for “es-ES” first. But upon not finding this specific culture, .NET will “fall back” to just the “es” portion of the locale string and will access the text as it exists in this new general Spanish file. Users using Mexican Spanish “es-MX” will see the same behavior.</p>



<p class="wp-block-paragraph"><strong>Common Pitfalls</strong></p>



<p class="wp-block-paragraph">Localization can be complicated, and there are some common pitfalls you may encounter if you are implementing your own localization solution. Here are some examples:</p>



<ul class="wp-block-list">
<li><strong>Logging / error messaging:</strong> if you are displaying raw exception messages to your users, then these are not able to be localized because they are generally hardcoded in English by the entities providing the error messages. In this case, your application should be updated to display custom error messages to your users instead of raw messages.</li>



<li><strong>Identifying EVERY source of user-facing text:</strong> There are many possible sources of text in your application that can go unnoticed, which can then become difficult to handle late in the localization process. Some examples are images, email templates, and messages from external libraries/packages/APIs. If you are doing frontend only localization, then it becomes necessary to make 100% certain that there is NO user facing text coming from the backend – if you discover late in the process that some user facing text comes from the server, then some “hacky” solutions may be necessary to preserve the frontend-only localization scheme.</li>



<li><strong>Not enforcing a single source of truth for text:</strong> If there is not a very solid system in place for establishing and updating the “source or truth” for translated text, then the localization process can quickly become messy. Things are always changing during development, and if there is not an established system to deliver text updates to translators and other stakeholders, then any one party can modify text without other stakeholders’ knowledge and introduce confusion. Enforce a single source of truth for text that all stakeholders can agree on. (Resource files are likely NOT the appropriate single source of truth, since non-developer stakeholders should also have control over text in the application.)</li>
</ul>



<div class="wp-block-group alignwide has-custom-light-blue-background-color has-background is-layout-flow wp-container-core-group-is-layout-dbd34961 wp-block-group-is-layout-flow" style="border-radius:20px;margin-top:var(--wp--preset--spacing--50);margin-bottom:var(--wp--preset--spacing--50);padding-top:var(--wp--preset--spacing--50);padding-right:0;padding-bottom:var(--wp--preset--spacing--50);padding-left:0">
<div class="wp-block-columns alignwide are-vertically-aligned-center is-layout-flex wp-container-core-columns-is-layout-43efaee5 wp-block-columns-is-layout-flex" style="padding-right:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:85%">
<h3 class="wp-block-heading has-text-align-left" id="h-have-an-upcoming-project-dmc-can-help-you-take-the-next-step"><strong>Build Applications That Speak Your Users’ Language</strong>.</h3>



<p class="has-text-align-left wp-block-paragraph" id="h-need-help-turning-ideas-into-outcomes-automation-project-to-the-next-level-contact-us-today-to-learn-more-about-our-solutions-and-how-we-can-help-you-achieve-your-goals">Check out our <a href="https://static.dmcinfo.com/services/application-development/" data-type="page" data-id="434">Application Development</a> solutions for JavaScript localization, multilingual interfaces, and scalable translation workflows with Visual Studio Code.</p>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<div class="wp-block-buttons is-horizontal is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-2236275c wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-fill"><a class="wp-block-button__link has-base-contrast-color has-text-color has-link-color wp-element-button" href="https://static.dmcinfo.com/contact/">Contact Us</a></div>
</div>
</div>
</div>
</div>
<p>The post <a href="https://static.dmcinfo.com/blog/15997/basic-javascript-localization-setup-using-json-with-visual-studio-code/">Basic JavaScript Localization Setup Using JSON with Visual Studio Code</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>
	</channel>
</rss>
