{"id":571,"date":"2017-05-17T11:52:00","date_gmt":"2017-05-17T16:52:00","guid":{"rendered":"https:\/\/blog.felineflock.com\/?p=571"},"modified":"2024-01-01T11:54:29","modified_gmt":"2024-01-01T17:54:29","slug":"genius-simple-trick-to-eliminate-repeated-spaces-in-salesforce-formulas","status":"publish","type":"post","link":"https:\/\/blog.felineflock.com\/index.php\/2017\/05\/17\/genius-simple-trick-to-eliminate-repeated-spaces-in-salesforce-formulas\/","title":{"rendered":"Genius Simple Trick to Eliminate Repeated Spaces in Salesforce Formulas"},"content":{"rendered":"\n<p>Neat trick that can be used in Salesforce formulas.<\/p>\n\n\n\n<p>It converts multiple spaces between words into a single space. This kind of cleaning would usually be done in Apex.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"974\" height=\"426\" src=\"https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/removingSpaces.jpeg\" alt=\"\" class=\"wp-image-572\" srcset=\"https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/removingSpaces.jpeg 974w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/removingSpaces-300x131.jpeg 300w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/removingSpaces-768x336.jpeg 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/figure>\n\n\n\n<p>The ~ and ^ could be any character but these were preferred because they are the least used in normal text and can still be typed.<\/p>\n\n\n\n<p>Charles Naccio (Salesforce Architect) used the following alternative to remove <strong>consecutive line breaks<\/strong> from an address field:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>TRIM(<br>\u00a0\u00a0\u00a0\u00a0SUBSTITUTE(<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SUBSTITUTE(<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SUBSTITUTE(SUBSTITUTE(Shipping_Street__c, SUBSTITUTE($Label.NewLine, &#8220;-&#8220;, &#8220;&#8221;), &#8221; &#8220;), &#8221; &#8220;, &#8220;~^&#8221;),<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8216;^~&#8217;,<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8221;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0),<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8216;~^&#8217;,<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8216; &#8216;<br>\u00a0\u00a0\u00a0\u00a0)<br>\u00a0\u00a0)<\/p>\n<\/blockquote>\n\n\n\n<p>The <em><strong>NewLine<\/strong><\/em> custom label is a workaround to detecting line breaks; the labels value is:<br>&#8211;<br>&#8211;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"594\" src=\"https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/newLine-1024x594.png\" alt=\"\" class=\"wp-image-573\" srcset=\"https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/newLine-1024x594.png 1024w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/newLine-300x174.png 300w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/newLine-768x446.png 768w, https:\/\/blog.felineflock.com\/wp-content\/uploads\/2024\/01\/newLine.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Neat trick that can be used in Salesforce formulas. It converts multiple spaces between words into a single space. This kind of cleaning would usually be done in Apex. The ~ and ^ could be any character but these were preferred because they are the least used in normal text and can still be typed. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-571","post","type-post","status-publish","format-standard","hentry","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts\/571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/comments?post=571"}],"version-history":[{"count":7,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts\/571\/revisions"}],"predecessor-version":[{"id":580,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/posts\/571\/revisions\/580"}],"wp:attachment":[{"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/media?parent=571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/categories?post=571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.felineflock.com\/index.php\/wp-json\/wp\/v2\/tags?post=571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}