{"id":6021,"date":"2017-05-08T17:50:34","date_gmt":"2017-05-08T17:50:34","guid":{"rendered":"http:\/\/www.jitendrazaa.com\/blog\/?p=6021"},"modified":"2017-05-22T19:19:41","modified_gmt":"2017-05-22T19:19:41","slug":"behold-yourself-summer-17-is-here-to-break-legacy-visualforce-navigation-code","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/behold-yourself-summer-17-is-here-to-break-legacy-visualforce-navigation-code\/","title":{"rendered":"Behold Yourself &#8211; Summer 17 is here to break legacy Visualforce Navigation code in Lightning Experience"},"content":{"rendered":"<p style=\"text-align: justify;\">You read it right. Its not <a href=\"https:\/\/developer.salesforce.com\/blogs\/developer-relations\/2016\/04\/introducing-lockerservice-lightning-components.html\">Locker Service<\/a> that may break your code, but <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/summer-17\/\">Summer 17<\/a>. If you have legacy Visualforce page, which needs to navigate to Lightning experience and <a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.pages.meta\/pages\/pages_variables_functions.htm\">URLFOR<\/a> is used <strong>directly<\/strong>, then chances of getting below error are very high.<\/p>\n<figure id=\"attachment_6023\" aria-describedby=\"caption-attachment-6023\" style=\"width: 840px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6023\" src=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?resize=840%2C368&#038;ssl=1\" alt=\"Salesforce Summer 17 - URLFOR Not working\" width=\"840\" height=\"368\" srcset=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?resize=1024%2C448&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?resize=300%2C131&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?resize=768%2C336&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-URLFOR-Not-working.png?w=1065&amp;ssl=1 1065w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption id=\"caption-attachment-6023\" class=\"wp-caption-text\">Salesforce Summer 17 &#8211; URLFOR Not working<\/figcaption><\/figure>\n<p>In above screenshot, I got\u00a0<strong>MALFORMED_ID : malformed Id\u00a0<\/strong>error in one of my Visualforce, where I needed to navigate to new Account record.<!--more--><\/p>\n<p><strong>Steps to reproduce error<\/strong><\/p>\n<p style=\"text-align: justify;\">Create below Visualforce in <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/summer-17\/\">Summer 17<\/a>, where Lightning experience is enabled.<\/p>\n<p><span style=\"text-decoration: underline;\">DemoURLFor.vfp<\/span><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n  &lt;apex:page standardController=&quot;Account&quot;&gt;\r\n Redirect Using URLFOR : &lt;a href=&quot;{!URLFOR($Action.Account.New, null, &#x5B;retURL='\/001',nooverride='1'], true)}&quot;&gt;\r\n URLFOR - Not working in Summer 17 Lightning Experience &lt;\/a&gt; &lt;br \/&gt;&lt;br \/&gt;\r\n Simple Redirect : &lt;a href=&quot;\/001\/e?retURL=%2F001%2Fo&amp;nooverride=1&quot;&gt;Direct - Not working in Summer 17 Experience&lt;\/a&gt; &lt;br \/&gt;&lt;br \/&gt;\r\n\r\n Working Example : &lt;a href=&quot;javascript:createAccount()&quot;&gt;Working with Summer 17 Experience&lt;\/a&gt; \r\n \r\n &lt;script type=&quot;text\/javascript&quot;&gt;\r\n function createAccount(){\r\n if( (typeof sforce != 'undefined') &amp;&amp; sforce &amp;&amp; (!!sforce.one) ) { \r\n sforce.one.createRecord('Account',null,{'retURL':'\/001','nooverride':'1'});\r\n }else{\r\n window.location='{!URLFOR($Action.Account.New, null, &#x5B;retURL='\/001',nooverride='1'], true)}';\r\n }\r\n } \r\n &lt;\/script&gt;\r\n&lt;\/apex:page&gt;\r\n<\/pre>\n<p style=\"text-align: justify;\">Next step is to override <strong>New button<\/strong> of Account by above Visualforce page.<\/p>\n<p style=\"text-align: justify;\">After this setup, if we try to create New Account, below page will appear.<\/p>\n<figure id=\"attachment_6024\" aria-describedby=\"caption-attachment-6024\" style=\"width: 933px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Override-New-button-in-Salesforce-Lightning-Experience.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6024\" src=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Override-New-button-in-Salesforce-Lightning-Experience.png?resize=933%2C397&#038;ssl=1\" alt=\"Override New button in Salesforce Lightning Experience\" width=\"933\" height=\"397\" srcset=\"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Override-New-button-in-Salesforce-Lightning-Experience.png?w=933&amp;ssl=1 933w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Override-New-button-in-Salesforce-Lightning-Experience.png?resize=300%2C128&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Override-New-button-in-Salesforce-Lightning-Experience.png?resize=768%2C327&amp;ssl=1 768w\" sizes=\"auto, (max-width: 933px) 100vw, 933px\" \/><\/a><figcaption id=\"caption-attachment-6024\" class=\"wp-caption-text\">Override New button in Salesforce Lightning Experience<\/figcaption><\/figure>\n<p style=\"text-align: justify;\">In above code, if we click first two URL, we will get an error. However, third URL will work.<\/p>\n<p style=\"text-align: justify;\">Key take away in this post is that, we need to use\u00a0<strong>sforce.one\u00a0<\/strong>object, which will be available by default in Lightning experience.<\/p>\n<p style=\"text-align: justify;\"><strong>Problem in above code and sforce.one API:<\/strong><\/p>\n<p style=\"text-align: justify;\">Above code will not be redirected properly on cancel button. so we can say <strong>even sforce.one is not full proof<\/strong>. In that scenario, we can use below snippet. Notice how URL is used here<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar simpleURL = '\/one\/one.app#\/sObject\/Account\/new?nooverride=1&amp;retURL=\/001' ; \r\n                sforce.one.navigateToURL(encodeURI(simpleURL));\r\n<\/pre>\n<p style=\"text-align: justify;\">Its too early to party \ud83d\ude41 . Above code will work only in Summer 17 but not in previous release.<\/p>\n<p style=\"text-align: justify;\">I was not able to find solution which will work in <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/summer-17\/\">Summer 17<\/a> as well as in <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/spring-17\/\">Spring 17<\/a>. Please drop a comment if you know the answer else we have to live with this code, as anyways all instances would be moved to <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/summer-17\/\">Summer 17<\/a> in few weeks.<\/p>\n<p style=\"text-align: justify;\">Below Video shows the issue and its fix discussed in this post.<\/p>\n<p><iframe loading=\"lazy\" title=\"Salesforce Summer17 URL issue\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/EFQ5fXcbXZU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p style=\"text-align: justify;\"><strong>Resources :<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/trailhead.salesforce.com\/en\/modules\/lex_dev_visualforce\/units\/lex_dev_visualforce_navigation\">Trailhead &#8211; Manage Navigation in Lightning experience\u00a0<\/a><\/li>\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.lightning.meta\/lightning\/ref_force_createRecord.htm\">force:createRecord &#8211; Lightning Component developer guide<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In Summer 17, URLFOR method in Visualforce would not work in Lightning Experience if used directly. Even sforce.one API is not fully compatible. <\/p>\n","protected":false},"author":1,"featured_media":6022,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[167,406],"class_list":["post-6021","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","tag-release","tag-summer-17"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/05\/Salesforce-Summer-17-Logo.gif?fit=460%2C325&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6142,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/show-lightning-component-on-public-website-without-authentication\/","url_meta":{"origin":6021,"position":0},"title":"Show Lightning component on public website without authentication","author":"Jitendra","date":"June 5, 2017","format":false,"excerpt":"How to show Lightning component on public sites without need of user authentication","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4618,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/most-frequently-used-code-snippets-for-salesforce-developers-faq-part-21\/","url_meta":{"origin":6021,"position":1},"title":"Salesforce Developers interview questions &#8211; Most commonly used code snippets &#8211; part 21","author":"Jitendra","date":"July 7, 2015","format":false,"excerpt":"Salesforce interview questions - Most frequently used Apex and visualforce code used by Salesforce developers like \"How to query and abort scheduled job using Apex\", \"Defining VF page as HTML5\", \"Visualforce page as JSON\" , \"Handling colon in element Id for Jquery\" , \"Chatter using Apex\" and many more.","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3347,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/ajax-based-autocomplete-component-in-salesforce-using-jquery-ui-and-json\/","url_meta":{"origin":6021,"position":2},"title":"AutoComplete Component in Visualforce using JQueryUI","author":"Jitendra","date":"June 28, 2013","format":false,"excerpt":"In this tutorial, I am going to explain very Simple AJAX and JSON based Auto Complete component with the help of JQuery UI. First I am assuming that you already have Static Resource of named \"AutoCompleteWithModal\"\u009d. This Static resource has all images, CSS and JQuery library needed to implement this\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"JQuery UI and JSON based AJAX AutoComplete Component in Salesforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/06\/JQuery-UI-and-JSON-based-AJAX-AutoComplete-Component-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2817,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/gantt-chart-in-salesforce-using-jquery-and-json\/","url_meta":{"origin":6021,"position":3},"title":"Gantt Chart in Salesforce using JQuery and JSON","author":"Jitendra","date":"April 18, 2012","format":false,"excerpt":"Tutorial and Example of creating the Gantt Chart in Salesforce using JQuery and JSON","rel":"","context":"In &quot;Apex&quot;","block_context":{"text":"Apex","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/apex\/"},"img":{"alt_text":"Gantt Chart in Salesforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/04\/Gantt-Chart-in-Salesforce.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":6232,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/winter-18-automatic-styling-of-visualforce-pages-in-lightning-experience\/","url_meta":{"origin":6021,"position":4},"title":"Winter 18 &#8211; Automatic Styling of Visualforce Pages in Lightning Experience","author":"Jitendra","date":"September 6, 2017","format":false,"excerpt":"How to use lightningStylesheets attribute to render Visualforce in Lightning Experience Stylesheet","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Winter 18 - Automatic Styling of Visualforce Pages in Lightning Experience","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/09\/Winter-18.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/09\/Winter-18.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/09\/Winter-18.gif?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":6222,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/use-visualforce-in-classic-and-lightning-experience\/","url_meta":{"origin":6021,"position":5},"title":"Use Visualforce in Classic and Lightning Experience","author":"Jitendra","date":"August 29, 2017","format":false,"excerpt":"How to design a Visualforce page so that It would be displayed properly in classic as well in Salesforce Lightning Experience","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Same Visualforce in classic and Lightning","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Same-Visiualforce-in-classic-and-Lightning.gif?fit=924%2C572&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Same-Visiualforce-in-classic-and-Lightning.gif?fit=924%2C572&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Same-Visiualforce-in-classic-and-Lightning.gif?fit=924%2C572&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2017\/08\/Same-Visiualforce-in-classic-and-Lightning.gif?fit=924%2C572&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=6021"}],"version-history":[{"count":13,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6021\/revisions"}],"predecessor-version":[{"id":6037,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6021\/revisions\/6037"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media\/6022"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=6021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=6021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=6021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}