{"id":2987,"date":"2012-08-02T14:03:55","date_gmt":"2012-08-02T08:33:55","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=2987"},"modified":"2015-02-09T01:30:50","modified_gmt":"2015-02-09T01:30:50","slug":"salesforce-interview-questions-part-10","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-interview-questions-part-10\/","title":{"rendered":"Salesforce Interview Questions \u2013 Part 10"},"content":{"rendered":"<div class=\"intrinsic-container\"><iframe loading=\"lazy\" src=\"https:\/\/jitendrazaa.com\/blog\/SFDCInterviewList.php?num=10\" width=\"300\" height=\"150\" allowfullscreen=\"allowfullscreen\"> <\/iframe><\/div>\n<p>This Part of Salesforce interview question series depict on <strong>browser compatibility issue<\/strong> (Internet Explorer 9) and Visualforce normally for AJAX,<strong> Group By<\/strong> and <strong>Having<\/strong> Clause.<\/p>\n<hr \/>\n<p><strong>91. How to add the Document Header in Visualforce page?<\/strong><br \/>\n<strong>Ans :<\/strong> Directly there is no way to add the document type in visualforce. However in most of the cases IE9 does not work with Visualforce pleasantly. And then we need to add the Document type in header. So following workaround will work.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;apex:outputText\r\nescape=&quot;false&quot;\r\nvalue=&quot;{!'&lt;!DOCTYPE html PUBLIC &quot;-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN&quot; &quot;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd&quot;&gt;'}&quot;\/&gt;\r\n&lt;html&gt;\r\n    &lt;head&gt;\r\n        &lt;title&gt;test&lt;\/title&gt;\r\n    &lt;\/head&gt;\r\n    &lt;body&gt;test&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n&lt;\/apex:page&gt;\r\n<\/pre>\n<p>Read more in detail in thread &#8211; <a title=\"IE 9 Problem\" href=\"http:\/\/boards.developerforce.com\/t5\/Visualforce-Development\/Changing-doctype-of-a-Visualforce-Page\/td-p\/82397\/page\/2\" rel=\"nofollow\">http:\/\/boards.developerforce.com\/t5\/Visualforce-Development\/Changing-doctype-of-a-Visualforce-Page\/td-p\/82397\/page\/2<\/a><\/p>\n<hr \/>\n<p><strong>92. Onchange event does not work with &lt;apex:actionsupport&gt; in IE9. How to resolve this error?<\/strong><br \/>\n<strong>Ans:<\/strong> If we hide the Header on Visualforce page then it creates lots of problem in IE9. I think there are few java-script library loaded by Header of Salesforce which makes IE9 compatible. So the best solution is to enable the Headre by using &#8220;showHeader=true&#8221; in Apex page.<br \/>\nRead more in detail in below thread URL :\u00a0<a title=\"Salesforce Onchange not working in IE 9\" href=\"http:\/\/boards.developerforce.com\/t5\/Apex-Code-Development\/IE9-requires-header-in-VF-Page\/td-p\/402997\" rel=\"nofollow\">http:\/\/boards.developerforce.com\/t5\/Apex-Code-Development\/IE9-requires-header-in-VF-Page\/td-p\/402997<\/a><\/p>\n<hr \/>\n<p style=\"text-align: justify;\"><strong>93. If IE9 is not working with your custom visualforce page then how to tell your visualforce code to run in IE8 compatibility mode?<\/strong><br \/>\n<strong> Ans:<\/strong><br \/>\nAdd following metatag to pages:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=EmulateIE8&quot; \/&gt;\r\n<\/pre>\n<hr \/>\n<p style=\"text-align: justify;\"><strong>94. It may happen that above tips will not work as lots of time the page header already sent. then how to achieve same result using Apex?<\/strong><br \/>\n<strong> Ans:<\/strong><br \/>\nAdd below line of code in Apex (Constructor)<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nApexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');\r\n<\/pre>\n<p><a title=\"Salesforce Intenet Explorer IE9 browser compatibility issue\" href=\"http:\/\/blogs.developerforce.com\/developer-relations\/2011\/03\/visualforce-rerender-and-internet-explorer-9.html\" rel=\"nofollow\">Read more tips and tricks to solve IE9 issue in Salesforce here.<!--more--><\/a><\/p>\n<hr \/>\n<p><strong>95. How to display the formatted number \/ date in Visualforce ? Which component should be used?<\/strong><br \/>\n<strong> Ans :<\/strong> Use component &#8220;&lt;apex:outputText&gt;&#8221;.<br \/>\nExample : Format the number into currency.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;apex:outputtext value=&quot;{0, number, 000,000.00}&quot;&gt;\r\n   &lt;apex:param value=&quot;{!valFromController}&quot; \/&gt;\r\n&lt;\/apex:outputtext&gt;\r\n<\/pre>\n<p>OR<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;apex:outputtext value=&quot;{0, number, ###,###.00}&quot;&gt;\r\n   &lt;apex:param value=&quot;{!valFromController}&quot; \/&gt;\r\n&lt;\/apex:outputtext&gt;\r\n<\/pre>\n<p><a title=\"apex:outputText\" href=\"http:\/\/www.salesforce.com\/us\/developer\/docs\/pages\/Content\/pages_compref_outputText.htm\" rel=\"nofollow\">Read in Detail , here<\/a><\/p>\n<hr \/>\n<p><strong>96. You want to display the Encrypted field on Visualforce and you are using component apex:outputText. Will it work for Encrypted fields?<\/strong><br \/>\n<strong>Ans :\u00a0<\/strong>Encrypted custom fields that are embedded in the &lt;apex:outputText&gt; component display in clear text. The &lt;apex:outputText&gt; component doesn&#8217;t respect the View Encrypted Data permission for users. To prevent showing sensitive information to unauthorized users, use the &lt;apex:outputField&gt; tag instead.<\/p>\n<hr \/>\n<p><em><span style=\"text-decoration: underline;\"><strong>Below Questions related to Group by clause in SOQL<\/strong><\/span><\/em><\/p>\n<p><strong>97. Will below query work? Explain.<\/strong><\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT COUNT(Id), Name, Address__c FROM Opportunity GROUP BY Name\r\n<\/pre>\n<p><strong>Ans :<\/strong><br \/>\nAbove query will throw an error.<br \/>\nExplanation : In Group by clause the columns selected must be either used in Group by clause or in aggregate functions. The Name field is neither used in aggregate methods and in group by clause and hence will result in error &#8220;Malformed Query&#8221;.<\/p>\n<p><a title=\"Group by documentation\" href=\"http:\/\/www.salesforce.com\/us\/developer\/docs\/api\/Content\/sforce_api_calls_soql_select_groupby.htm\">Read more here in detail &#8211; Group by Documentation<\/a><\/p>\n<hr \/>\n<p><strong>98. Explain difference in COUNT() and COUNT(fieldname) in SOQL.<\/strong><br \/>\n<strong> Ans :<\/strong><\/p>\n<p><span style=\"text-decoration: underline;\"><strong>COUNT()<\/strong><\/span><\/p>\n<ul>\n<li>COUNT() must be the only element in the SELECT list.<\/li>\n<li>You can use COUNT() with a LIMIT clause.<\/li>\n<li>You can&#8217;t use COUNT() with an ORDER BY clause. Use COUNT(fieldName) instead.<\/li>\n<li>You can&#8217;t use COUNT() with a GROUP BY clause for API version 19.0 and later. Use COUNT(fieldName) instead.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\"><strong>COUNT(fieldName)<\/strong><\/span><\/p>\n<ul>\n<li>You can use COUNT(fieldName) with an ORDER BY clause.<\/li>\n<li>You can use COUNT(fieldName) with a GROUP BY clause for API version 19.0 and later.<\/li>\n<\/ul>\n<p><a title=\"Salesforce documentation for COUNT() and COUNT(fieldname)\" href=\"http:\/\/www.salesforce.com\/us\/developer\/docs\/api\/Content\/sforce_api_calls_soql_select_count.htm\">Read here in more detail about COUNT() and COUNT(fieldname)<\/a><\/p>\n<hr \/>\n<p><strong>99. How to write the &#8220;Where&#8221; clause in SOQL when GroupBy is used for aggregate functions?<\/strong><br \/>\n<strong> Ans :<\/strong> We cannot use the &#8220;<strong>Where<\/strong>&#8221; clause with GroupBy for aggregate functions like SUM() instead we will need to use the &#8220;<strong>Having Clause<\/strong>&#8220;.<br \/>\n<span style=\"text-decoration: underline;\"><strong>Example :<\/strong> <\/span>Get all the opportunity where more than one record exists with same name and name contains &#8220;ABC&#8221;.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT COUNT(Id) , Name FROM Opportunity GROUP BY Name  Having COUNT(Id) &gt; 1 AND Name like '%ABC%'\r\n<\/pre>\n<p><a title=\"Having Clause in SOQL Salesforce\" href=\"http:\/\/www.salesforce.com\/us\/developer\/docs\/soql_sosl\/Content\/sforce_api_calls_soql_select_having.htm\" rel=\"nofollow\">Read more about Having clause<\/a><\/p>\n<hr \/>\n<p><strong>100. Lets consider that the first component in VF page is the Datepicker. In that case whenever the page loads, salesforce auto focus the first component resulting in Datepicker onfocus event. Because of this the Datepicker component opens automatically. How we can avoid this?<\/strong><br \/>\n<strong> Ans :<\/strong><\/p>\n<p>On load event, write the javascript code to autofocus any other field or any other non-visible component.<br \/>\nExample :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;span id=&quot;focusDistraction&quot;&gt;&lt;\/span&gt;\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n\t\/* prevent autopup of the date inputfield by the default focus behavoir *\/\r\n\twindow.onload=function() {\r\n\tdocument.getElementById('focusDistraction').focus();\r\n\t}\r\n&lt;\/script&gt;\r\n<\/pre>\n<hr \/>\n<div class=\"intrinsic-container\"><iframe loading=\"lazy\" src=\"https:\/\/jitendrazaa.com\/blog\/SFDCInterviewList.php?num=10\" width=\"300\" height=\"150\" allowfullscreen=\"allowfullscreen\"> <\/iframe><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This Part of Salesforce interview question series depict on browser compatibility issue (Internet Explorer 9) and Visualforce normally for AJAX, Group By and Having Clause. 91. How to add the Document Header in Visualforce page? Ans : Directly there is no way to add the document type in visualforce. However in most of the cases [&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_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":[337,50,116,331,185],"class_list":["post-2987","post","type-post","status-publish","format-standard","hentry","category-salesforce","tag-apex","tag-browser","tag-ie9","tag-salesforce","tag-soql"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3134,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-helptext-like-custom-tooltip-using-jquery\/","url_meta":{"origin":2987,"position":0},"title":"Salesforce Helptext like Custom Tooltip using JQuery","author":"Jitendra","date":"February 4, 2013","format":false,"excerpt":"Welcome back Readers. This is my first blog entry for year 2013, i know its too late. However i can ensure that i have lots of unique post which will come this year. I am starting this year with very light post , mimic the help-text style of Salesforce. Download\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"Salesforce like Helptext - Tooltip using JQuery","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/02\/Salesforce-like-Tooltip-using-JQuery.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":28,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-interview-questions\/","url_meta":{"origin":2987,"position":1},"title":"Salesforce Interview Questions &#8211; Part 1","author":"Jitendra","date":"May 6, 2010","format":false,"excerpt":"Set of most often asked questions on the salesforce.com developement","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":2470,"url":"https:\/\/www.jitendrazaa.com\/blog\/webtech\/salesforce-tutorial-create-simple-ajax-based-visualforce-page\/","url_meta":{"origin":2987,"position":2},"title":"Salesforce Tutorial &#8211; Create Simple Ajax based Visualforce page","author":"Jitendra","date":"October 17, 2011","format":false,"excerpt":"Salesforce Tutorial - Step by step tutorial to create AJAX based application in visualforce page with Apex class","rel":"","context":"In &quot;Web Technology&quot;","block_context":{"text":"Web Technology","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/"},"img":{"alt_text":"Simple AJAX demo in salesforce using visualforce","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/10\/Simple-AJAX-demo-in-salesforce-using-visualforce.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3773,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-faq-part-19\/","url_meta":{"origin":2987,"position":3},"title":"Salesforce interview questions &#8211; Part 19","author":"Jitendra","date":"December 16, 2014","format":false,"excerpt":"Salesforce interview questions for developers and admins around Apex, Visualforce, getting Salesforce object name on basis of Id, Apex API limits","rel":"","context":"In &quot;Apex&quot;","block_context":{"text":"Apex","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/apex\/"},"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":2987,"position":4},"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":4102,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/salesforce-faq-part-20-lightning-questions\/","url_meta":{"origin":2987,"position":5},"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":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/2987","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=2987"}],"version-history":[{"count":3,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/2987\/revisions"}],"predecessor-version":[{"id":4225,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/2987\/revisions\/4225"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=2987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=2987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=2987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}