{"id":3706,"date":"2014-02-16T13:36:15","date_gmt":"2014-02-16T08:06:15","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=3706"},"modified":"2014-03-31T05:43:16","modified_gmt":"2014-03-31T05:43:16","slug":"introduction-to-visualforce-remote-objects","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/visualforce\/introduction-to-visualforce-remote-objects\/","title":{"rendered":"Visualforce Remote Objects"},"content":{"rendered":"<p style=\"text-align: justify;\">One of the exciting feature of Spring14 release is introduction of &#8220;Visualforce Remote Objects&#8221;. You can say its actually replacement of <a title=\"JavaScript Remoting for Apex Controllers\" href=\"http:\/\/www.salesforce.com\/us\/developer\/docs\/pages\/Content\/pages_js_remoting.htm\">JavaScript Remoting<\/a>.<\/p>\n<p><strong>Why do we need &#8220;Visualforce Remote Objects&#8221; when we already have &#8220;JavaScript Remoting&#8221; ?<\/strong><\/p>\n<p style=\"text-align: justify;\">Well, here are few advantages of &#8220;Visualforce Remote Objects&#8221; :<\/p>\n<ol>\n<li style=\"text-align: justify;\">No need to write Controllers, Everything can be done in Visualforce only.<\/li>\n<li style=\"text-align: justify;\">As <em>@RemoteAction<\/em> annotated methods needs to be static so you had to take special precaution as it didn&#8217;t supported Viewstate. This hurdle is completely removed now.<\/li>\n<li style=\"text-align: justify;\">No need to write Test Class now, as no Controller is involved.<\/li>\n<\/ol>\n<p><strong><!--more-->How to start with this ?<\/strong><\/p>\n<p>At time of writing this article, This feature is under Pilot release. So, you have to contact Salesforce support to enable it in your Organization.<\/p>\n<p>Visualforce code Sample :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!-- This Demo will assume Querying Account Object --&gt;\r\n&lt;apex:remoteObjects&gt;\r\n&lt;apex:remoteObjectModel name=&quot;Account&quot; jsShorthand=&quot;getActs&quot; fields=&quot;Name,Id&quot;&gt;\r\n &lt;apex:remoteObjectField name=&quot;ClientType__c&quot; jsShorthand=&quot;cType&quot;&gt;\r\n&lt;\/apex:remoteObjectModel&gt;\r\n&lt;\/apex:remoteObjects&gt;\r\n<\/pre>\n<p style=\"text-align: justify;\">you can see in above code, few new Visualforce tags are introduced like &#8220;<em>remoteObjectModel<\/em>&#8221; and &#8220;<em>remoteObjectField<\/em>&#8220;.<\/p>\n<p style=\"text-align: justify;\"><em>jsShorthand<\/em> attribute defines shortcut that can be used inside your JavaScript code. Now, we don&#8217;t have to write annoying object or field name ending with &#8220;__c&#8221; or namespace name. This will keep our code tidy.<\/p>\n<p style=\"text-align: justify;\">Javascript code Sample :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/Create new Remote Object Reference\r\nvar src = new SObjectModel.getActs();\r\n\r\n\/\/Use Remote Object to query 5 records\r\nsrc.retrieve({\r\n\t\t\tlimit : 10,\r\n\t\t\twhere : {\r\n\t\t\t\tcType :{\r\n\t\t\t\t\teq : 'Banking'\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t} ,\r\n\t\tfunction(err,records){\r\n\t\t\tif(err == null)\r\n\t\t\t{\r\n\t\t\t\t\/\/Process returned &quot;records&quot; to display in Visualforce code.\r\n\t\t\t}\r\n} );\r\n<\/pre>\n<p style=\"text-align: justify;\">In above code, we are calling <em>retrieve()<\/em> method of Javascript object <em>SObjectModel<\/em>. Once you get records, you can process it in your javascript. Other than <em>retrieve()<\/em> , you can perform all CRUD operations on object.<\/p>\n<p>You can see below articles also on same topic.<\/p>\n<ul>\n<li><a title=\"Spring'14 Visualforce Remote Objects Introduction - By Andy\" href=\"http:\/\/andyinthecloud.com\/2014\/01\/22\/spring14-visualforce-remote-objects-introduction\/\">Spring&#8217;14 Visualforce Remote Objects Introduction<\/a><\/li>\n<li><a title=\"Visualforce Remote Objects - Pilot - Release Notes\" href=\"http:\/\/docs.releasenotes.salesforce.com\/en-us\/api\/release-notes\/rn_vf_remote_objects.htm\">Visualforce Remote Objects &#8220;\u201d Pilot &#8211; Release Notes<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>One of the exciting feature of Spring14 release is introduction of &#8220;Visualforce Remote Objects&#8221;. You can say its actually replacement of JavaScript Remoting. Why do we need &#8220;Visualforce Remote Objects&#8221; when we already have &#8220;JavaScript Remoting&#8221; ? Well, here are few advantages of &#8220;Visualforce Remote Objects&#8221; : No need to write Controllers, Everything can be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_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_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[18],"tags":[127,156,168,331,186,336],"class_list":["post-3706","post","type-post","status-publish","format-standard","hentry","category-visualforce","tag-javascript-remoting","tag-pilot","tag-remote-objects","tag-salesforce","tag-spring14","tag-visualforce"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2874,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/introduction-to-view-state-in-visualforce\/","url_meta":{"origin":3706,"position":0},"title":"Introduction to View State in Visualforce","author":"Jitendra","date":"June 1, 2012","format":false,"excerpt":"Introduction to View State in Visualforce with example and code walk-through","rel":"","context":"In &quot;Apex&quot;","block_context":{"text":"Apex","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/apex\/"},"img":{"alt_text":"View State in Salesforce before Postback","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/05\/View-State-in-Salesforce-before-Postback-1024x287.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/05\/View-State-in-Salesforce-before-Postback-1024x287.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2012\/05\/View-State-in-Salesforce-before-Postback-1024x287.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":4486,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/continuation-object-in-apex-asynchronous-callouts-for-long-running-request-live-demo\/","url_meta":{"origin":3706,"position":1},"title":"Continuation object in Apex &#8211; Asynchronous callouts for long running request &#8211; Live Demo","author":"Jitendra","date":"May 22, 2015","format":false,"excerpt":"Check the below video first if you are planning to use Continuation https:\/\/youtu.be\/ya2N9EX9dmg We may run into\u00a0scenario in Salesforce project, where we need call external web service but no need to\u00a0wait for response. Response from external web service can be processed asynchronously and once processed it can be presented in\u2026","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Execution Flow of an Asynchronous Callout - Image from Salesforce documentation","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/apex_continuations_diagram.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/apex_continuations_diagram.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/apex_continuations_diagram.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2015\/05\/apex_continuations_diagram.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":4107,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-drag-and-drop-file-uploader-component-with-progress-bar-html5-and-pure-javascript-based\/","url_meta":{"origin":3706,"position":2},"title":"Salesforce &#8211; Drag and Drop File Uploader Component with Progress Bar &#8211; HTML5 and Pure Javascript Based","author":"Jitendra","date":"December 19, 2014","format":false,"excerpt":"You may find many ways to upload attachments in Salesforce using\u00a0visualforce\u00a0however most of them uses some Javascript libraries (means either you need to depend on static resources or add CDN in remote site settings) or they do not have progress bar or they are not drag and drop. I thought\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"HTML5 Drag And Drop File","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/12\/HTML5-Drag-And-Drop-File-1024x205.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/12\/HTML5-Drag-And-Drop-File-1024x205.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/12\/HTML5-Drag-And-Drop-File-1024x205.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2649,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/get-dom-elementid-of-the-visualforce-components\/","url_meta":{"origin":3706,"position":3},"title":"Get DOM ElementID of the Visualforce components","author":"Jitendra","date":"January 19, 2012","format":false,"excerpt":"How to get the DOM ElementID of the Visualforce components in Salesforce","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":4102,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-faq-part-20-lightning-questions\/","url_meta":{"origin":3706,"position":4},"title":"Salesforce interview question related to Lightning framework &#8211; Part 20","author":"Jitendra","date":"February 4, 2015","format":false,"excerpt":"Salesforce interview questions for Salesforce developers and admin , mostly related to newly released Salesforce Lightning components and applications","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":5332,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/spell-checker-in-custom-visualforce-page\/","url_meta":{"origin":3706,"position":5},"title":"Spell checker in custom Visualforce page","author":"Jitendra","date":"February 15, 2016","format":false,"excerpt":"Using Salesforce Spell checker in custom Visualforce pages","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"Spell checker in custom Visualforce page","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/02\/Spell-checker-in-custom-Visualforce-page.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/02\/Spell-checker-in-custom-Visualforce-page.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/02\/Spell-checker-in-custom-Visualforce-page.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2016\/02\/Spell-checker-in-custom-Visualforce-page.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3706","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=3706"}],"version-history":[{"count":2,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3706\/revisions"}],"predecessor-version":[{"id":3795,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/3706\/revisions\/3795"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=3706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=3706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=3706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}