New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK

VISUAL FORCE

100 comments:

  1. no view state for standard controller

    ReplyDelete
    Replies
    1. we can create a vf page with in the component it will display viewsate.

      Delete
    2. we can create a vf page with in the component it will display viewsate.

      Delete
    3. we can create a vf page with in the form component it will display viewsate.

      Delete
  2. Pagenation:
    http://blog.redpointsolutions.com/bid/182738/Add-Pagination-to-your-Visualforce-Pages-using-the-SOQL-OFFSET-Clause

    ReplyDelete
  3. On VF Page maximum of 1000 records we can display.

    ReplyDelete
  4. To dispaly name along with field type in case of standard controller put inputField in pageBlockSection:
    -----------------------------------------


    ReplyDelete
  5. Inlineedit Save freeze with VisualForce Apex:include
    Solution:http://boards.developerforce.com/t5/Visualforce-Development/Inlineedit-Save-freeze-with-VisualForce-Apex-include/td-p/479327

    ReplyDelete
  6. Read Only attribute of VF Page:
    http://boards.developerforce.com/t5/Apex-Code-Development/System-LimitException-Too-many-DML-statements-1/m-p/444541#M80847

    ReplyDelete
    Replies
    1. Too many DML statements: 151

      Delete
    2. Too many DML statements: 1

      Delete
  7. a href dynamic url format:
    http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/61050/print-single-message/false/page/1

    ReplyDelete
  8. Pagination without using Offset in Saleforce:

    http://cloudforce4u.blogspot.com/2013/06/visualforce-component-for-pagination-in.html

    ReplyDelete
  9. http://salesforce.stackexchange.com/questions/14217/error-while-trying-to-use-sforce-apex-execute

    ReplyDelete
  10. Setting tab focus in salesforce:
    http://boards.developerforce.com/t5/Visualforce-Development/Visualforce-taborder-How-to-set-focus-on-the-first-field-if-it/m-p/510691#M56628

    ReplyDelete
  11. Redirecting VF Page using Standard Save button:
    http://salesforce.stackexchange.com/questions/3907/redirecting-back-to-original-page-using-visualforce

    ReplyDelete
  12. To check validation error messages for standard controller:
    !ApexPages.hasMessages()

    ReplyDelete
  13. Wrapper Class Sorting:
    http://www.tgerm.com/2012/05/apex-comparable-sorting-examples-part-2.html

    ReplyDelete
  14. Fetching Server URL in Visualforce Template:
    {!LEFT($Api.Partner_Server_URL_140, FIND('.com/',$Api.Partner_Server_URL_140)+3)}
    Refer:
    http://salesforce.stackexchange.com/questions/4696/trying-to-put-server-name-into-a-url-for-email-template

    ReplyDelete
  15. Setting the window size in javascript:
    window.moveTo(0,0)
    window.resizeTo(screen.width,screen.height);

    ReplyDelete
    Replies
    1. Use above lines in a function and call from window.onload = functionName

      Delete
  16. Setting Email Template in code without using settargerobjectid:
    http://techman97.wordpress.com/2013/10/08/sending-email-template-via-apex-no-targetobjectid/

    ReplyDelete
  17. Popup window using javascript with the screen full size:
    window.open('url' ,'','height=1000,width=1400,left=0,resizable=yes,scrollbars=yes', 0);

    ReplyDelete
  18. To make the page block table height constant:
    apex:outputpanel layout="block"
    div id="divsrchResults" style="height:200px;overflow:scroll;overflow-x: hidden;"
    Pageblock Table.....
    /div
    /apex:outputpanel

    ReplyDelete
  19. using stypeclass value brandTertiaryBgr pbSubheader tertiaryPalette in salesforce:
    http://writeforce.blogspot.com/2012/10/improving-our-search-functionality-by.html

    ReplyDelete
    Replies
    1. Typo: stypeclass* , styleclass

      Delete
  20. To hide the field label in salesforce:
    &nbsp

    ReplyDelete
  21. javascript methods:
    http://stackoverflow.com/questions/7720061/window-opener-location-href-works-in-ie-but-not-chrome-or-safari
    http://forums.asp.net/t/1198828.aspx
    Capturing parameters in javascript:
    '{!$CurrentPage.parameters.parameter names}'

    ReplyDelete
  22. Custom Section Header Icon in salesforce:
    http://blogforce9.blogspot.in/2013/01/custom-section-header-icons-for-vf-pages.html

    ReplyDelete
  23. Tab Icons reference names:
    http://free-121d5f44d20-121d603d1c5-121ee2b8103.force.com/force2b/salesforceicons

    ReplyDelete
  24. Customizing salesforce style:
    https://developer.salesforce.com/forums/ForumsMain?id=906F00000008muxIAA

    Use below code to hide the salesforce header:
    style
    .bPageHeader {
    display:none;
    }
    /style

    ReplyDelete
  25. Error due to Database.queryLocator: (after we keep it ideal):
    "this page uses a query locator that is invalid. there is a limit of 50 querylocators per object"

    ReplyDelete
  26. Inserting multiple records at a time in salesforce:
    http://bobbuzzard.blogspot.in/2011/07/managing-list-of-new-records-in.html

    ReplyDelete
  27. Good Advanced Pagination Salesforce:
    Previous First 1 2 3 4 5 .... Last Next

    http://demo.redpointsolutions.com/Dynamic_Visualforce_with_SOQL_Offset

    ReplyDelete
  28. Hiding header and side bar for standard salesforce record (not visualforce):
    http://mindfiresfdcprofessionals.wordpress.com/2013/09/page/2/

    ReplyDelete
  29. To display help icon symbol on visualforce page salesforce:
    http://mindfiresfdcprofessionals.wordpress.com/2013/09/28/help-icon-symbol-not-showing-in-visualforce-page/

    ReplyDelete
  30. Displaying Batch job status in salesforce:
    http://www.tehnrd.com/batch-apex-status-bar/

    ReplyDelete
  31. Salesforce News:
    http://blog.deliveredinnovation.com/salesforce-business-logic/

    ReplyDelete
  32. Server side pagination using wrapper class vusualforce page:
    http://www.sundoginteractive.com/sunblog/posts/server-side-pagination-in-apex-visualforce-for-custom-classes

    ReplyDelete
  33. Giving single quotes within the string:
    ' FieldName like \''+String.escapeSingleQuotes(Fieldname)+'\'';

    ReplyDelete
  34. apex:page
    style
    a {background:#ccc url("../img/sprite-icons.png") no-repeat scroll -360px -100px transparent;
    height:14px; width:12px;}

    a:hover { background:#f00 url("../img/sprite-icons.png") no-repeat scroll -360px -100px transparent;}

    .readmoreall { height:20px; width:40px; background:#ccc; display:table; padding:0px 0 0 20px;}

    .readmore {background:#ccc url("/servlet/servlet.FileDownload?file=01590000002qDgb") no-repeat scroll -355px -100px;
    text-indent:-9999px; display:block; height:20px; width:20px;}

    .readmore:hover { background:#f00 url("/servlet/servlet.FileDownload?file=01590000002qDgb") no-repeat scroll -355px -100px;}
    style

    div class="readmoreall"
    a href="www.google.com" class="readmore">Read</a
    div
    apex:page

    ReplyDelete
  35. apex:page
    style
    .myButtonLink {
    display: block;
    width: 50px;
    height: 30px;
    background: url('/servlet/servlet.FileDownload?file=01590000002qDwZ') bottom;
    text-indent: -99999px;
    }
    .myButtonLink:hover {
    display: block;
    width: 50px;
    height: 30px;
    background: url('/servlet/servlet.FileDownload?file=01590000002qDy6') bottom;
    text-indent: -99999px;
    }
    /style

    a class="myButtonLink" href="#LinkURL">Leaf/a
    /apex:page

    ReplyDelete
  36. Hi this is ThirupathiReddy

    ReplyDelete
  37. While clicking on a command button to avoid standard validations use immediate = "true".

    ReplyDelete
  38. Closing the parent window using javascript:
    function refreshParent() {
    window.opener.location.href = window.opener.location.href;
    if (window.opener.progressWindow){
    window.opener.progressWindow.close()
    }
    window.close();
    }

    ReplyDelete
  39. To display loading image when you click on a button, use below line within facet start (include in output panel along with command button):
    apex:image value="/img/loading32.gif" style="height: 15px;"

    ReplyDelete
  40. To maintain fixed height & length for page-block use below line:
    div id="results" style="height:200px;overflow:scroll;overflow-x: hidden;"

    ReplyDelete
  41. Number wise pagination

    ReplyDelete
    Replies
    1. http://demo.redpointsolutions.com/Dynamic_Visualforce_with_SOQL_Offset

      Delete
  42. Building an angular JS App:
    http://www.toptal.com/angular-js/a-step-by-step-guide-to-your-first-angularjs-app

    ReplyDelete
  43. Sublime Text Editor

    ReplyDelete
  44. Rendering the pdf in different pages and giving page number for each page:
    https://help.salesforce.com/apex/HTViewSolution?urlname=Formating-VisualForce-Page-rendered-as-PDF-1327108686696&language=en_US

    ReplyDelete
  45. To send special characters(&, etc..) in the url use below format to send the values in VF pages:
    EncodingUtil.urlEncode(Value,,'UTF-8')

    ReplyDelete
  46. Display all the lines of list in order:
    li style="list-style-position: outside;"

    ReplyDelete
  47. VF-Stadrd contrl-without pring fields on VF page- if we user getRecord below error will come - It can remember only Id by default: Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field.

    ReplyDelete
  48. Displaying number of records which are coming due to a rest call out on record detail page with inline visualforce, sometimes which is causing read time out error, to avoid this with onload of javascript, call controller class method display the status, oncomplete hide the status. To capture read time out error while making callout put in try and catch block

    ReplyDelete
  49. We cannot edit the 'Save' button.

    ReplyDelete
  50. After saving, to navigate to some other url customize new button and append 'SAVEURL' to url.

    ReplyDelete
  51. After Saving the record, How to navigate to some other url apart from detail page?
    customize new button > append 'saveURL = /'
    Note:
    - saveURL is Case - Sensitive.
    - URL encoding for / is '%2F'
    If we click on cancel, how to navigate to some other url?
    Customize new button > append 'restURL = %2F'
    Note:
    - %2F means '/'
    - retURL is Case - Sensitive.
    - in the same URL if we have both retURL and saveURL then if click on cancel it take retURL and if we click on save, it take saveURL.

    ReplyDelete
  52. Small correction: Customize new button > append 'retURL = %2F'

    ReplyDelete
  53. Overriding the buttons:
    for the standard buttons, we cannot override button with java script only for the custom buttons, it will be available.

    ReplyDelete
  54. onload if we give url navigation, it is keep on looping, How to avoid this?

    ReplyDelete
    Replies
    1. In the URL please append 'nooverride=1' while overriding the new buttons please use vf page and in javascript include onload = function {document.location.href = url}

      Delete
  55. Hiding the inline visualforce page: Use id of the visualforce page in javascript to hide.

    ReplyDelete
    Replies
    1. Use the following script to hide the inline visualforce page:
      function fnName() {
      var ifrm = parent.document.getElementById('Id of the vf page');
      ifrm.style.height = "5px";
      ifrm.style.visibility = "hidden";
      }
      window.onload = fnName();

      Delete
  56. Forming html inside of a string value:
    'tr'+'td'+'somevalue'+'td'+'td'+'somevalue'+'td'+'td'+'somevalue'+'td'+'td'+'somevalue'+'td'+'tr'
    Note: Add less than and greater than symbols.

    ReplyDelete
  57. ActionSupport is not working:
    From inside of the pageBlockSectionItem actionSupport won't work.

    ReplyDelete
  58. mouse event are not working:
    for output Text mouse events won't work use output label.

    ReplyDelete
  59. Upon clicking on a button from the list of cases which belongs to a Queue with name 'Queue A' will be assigned to the requested user.
    If both the users request a same case at sametime (If it is in Sec gap) then first it it assigning to one user and then immediately it is assigning to other user.
    But once the case is assigned to one user it should not be assigned to some other user.

    For the above scenario take validation rule, in that mention if the previous owner doesn't belongs to the queue then throw the validation rule (Upon updating validation rules will fire). In the Controller Class exception block we can capture this error message.

    Now in the actionFunction function take onComplete attribute which will invoke if we return null as pageReference in the controller class. (Note: If we don't return null then onComplete won't invoke).

    From onComplete call a javaScript method by passing the boolean value as parameter (Note: make this boolean value as true if it enters in to the our validation error exception block). We should pass boolean value as parameter while calling javaScript function otherwise it won't take the latest value. If you print the boolean value in the alert then make sure that you are rerendering that javaScript code also from the actionFunction.

    In javaScript if the boolean value is true then call the actionFunction one more time (For other exceptions we are not calling this one more time).

    This actionFunction is getting call for the javaScript onLoad event.

    ReplyDelete
    Replies
    1. This is an example of actionFunction Chaining.

      Delete
  60. Displaying a window as popup:
    apex:outputLink title="View detail in a popup window" onclick="return openPopup('{!acc.Id}');"Detailsapex:outputLink

    script
    function openPopup(id)
    {
    var newWin=window.open('{!$Page.Popup}?id=' + id, 'Popup',
    'height=600,width=650,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
    if (window.focus)
    {
    newWin.focus();
    }

    return false;

    }
    script

    ReplyDelete
  61. Use escape for save url or else give asci code for &

    ReplyDelete
    Replies
    1. We should use URLENCODE() for both retURL and saveURL

      Delete
  62. For inputField displaying error message on the page:
    div class="errorMsg" style="display:{!IF(accountIdVal.hasError,'block','none')}">strongError:/strong {!accountIdVal.error}/div

    ReplyDelete
  63. Date format in Visualforce Page:


    ReplyDelete
    Replies
    1. apex:outputText value=”{0,date,M/d/yyyy hh:mm a}”
      apex:param value=”{!Account.createdDate}”
      /apex:outputText

      Delete
  64. Currency symbol in Vf page:
    apex:outputText value="${0, number, ###,###,###,##0.00}"
    apex:param value="{!Account.Amount__c}"/
    /apex:outputText>
    Refer: http://blogforce9.blogspot.com/2012/12/currency-formatting-in-visualforce-page.html

    ReplyDelete
  65. Salesforce Standard Section Style:

    style
    .detailList1 {
    width: 100%;
    }
    .detailList1 .labelCol{
    padding-right: 10px;
    padding-left: 2px;
    text-align: right;
    font-size: 91%;
    font-weight: bold;
    color: #4a4a56;
    width: 16%;
    padding-top: 3px;
    padding-bottom: 3px;
    }
    .detailList1 .dataCol{
    width: 33%;
    text-align: left;
    padding-top: 3px;
    padding-right: 2px;
    padding-bottom: 2px;
    padding-left: 12px;
    text-align: left;
    }
    .detailList1 .labelCol1{
    padding-right: 10px;
    padding-left: 2px;
    text-align: right;
    font-size: 91%;
    font-weight: bold;
    color: #4a4a56;
    width: 19%;
    padding-top: 3px;
    padding-bottom: 3px;
    }
    .detailList1 td{
    border-bottom:1px dotted #ececec;
    }
    /style

    table class="detailList1"
    tbody
    tr
    td class="labelCol"Test1/td
    td class="dataCol col02"Test2/td
    td class="labelCol1"Test3/td
    td class="dataColTest4/td
    /tr
    tr
    td class="labelCol"Test1/td
    td class="dataCol col02"Test1/td
    td class="labelCol1"Test1/td
    td class="dataCol"Test1/td
    /tr
    tr
    td class="labelCol"Test1/td
    td class="dataCol col02"Test1/td
    /tr
    /tbody
    /table

    ReplyDelete
  66. To clone the record, please follow as mentioned below -
    ------
    cloneURL = '/'+recordId+'/e?clone=1

    ReplyDelete
  67. Advanced Visualforce Development with JavaScript:
    1. JavaScript Rmoting
    2. Remote Objects
    Refer:
    https://developer.salesforce.com/events/webinars/advanced_visualforce_development?cta=text

    ReplyDelete
  68. Displaying Google Chart while generating PDF:
    https://anythingforeveryone.wordpress.com/2015/02/28/i-want-to-put-a-google-chart-inside-a-visualforce-page-rendered-as-pdf-is-that-possible-yes/

    ReplyDelete
  69. Communication between Visualforce Component and Visualforce page:
    https://developer.salesforce.com/page/Controller_Component_Communication

    ReplyDelete
  70. 1. 1, 2, 3, 2, 1, 2, 3, 2, 1, ... generating with apex code?
    2. Upon clicking on account name related contacts should display.

    ReplyDelete
  71. Incase of using 'recordSetVar', for the child objects (contact, case, employee__c) we should give the id in url but for the Parent objects without id it can display all the records.

    ReplyDelete
  72. Lightning Findings -
    We cannot refresh svg icons tables in VF page.
    Reference: https://github.com/salesforce-ux/design-system/issues/47

    ReplyDelete
  73. In package custom fields are not recognizing after giving name space also.
    1. Used Remote Objects to query from the database but displayed 'full custom field API Name should be specified',
    followed all the best approaches using shorthand for the custom fields, but not able to resolve the issue.
    2. Directly used javaScript using sforce.connect still same problem
    3. maintained the logic in apex class from the return type of the apex class, splitting the info. and displaying the information on the page.
    4. Remote Object Model, sforce.connect will enforce user security.

    Resolution: Finally found that for all the custom fields didn't give permission to any of the profile.
    (while querying in the developer console also same problem came)
    After giving permissions it started working.

    ReplyDelete
  74. LastViewDate Issue while querying from using SQL -
    https://success.salesforce.com/issues_view?id=a1p30000000T0tvAAC

    ReplyDelete
  75. apex expression in javaScript should be "{!variableName}" for String data types.
    apex expression in javaScript should be {!variableName} for Integer data types.

    ReplyDelete
  76. Custom Permissions -
    1. Create a custom permission
    2. Go to profile and navigate to custom permissions section and add the permission to profile/permission set
    3. Refer the permission on VF page {!$permission.permissionName}.
    4. In apex bit difficult syntax to use.

    ReplyDelete
  77. Calling Aura Method:
    while calling Aura method while setting parameters in JS Controller/helper param names should be same as controller class params.

    ReplyDelete
  78. Passing Parameters to ActionFunction -
    While passing parameters through action function 'rerender' should be used or else parameters won't be passed. (will result in null)

    ReplyDelete
  79. Taking page back and forward -
    window.history.back() to go back to the previous page.
    window.history.forward() to go to the next page.

    ReplyDelete
  80. Accessing visuaforce page url from managed package javaScript -
    Use /apex/c__ApexPageName while invoking URL from the javaScript of the Managed package.

    ReplyDelete
  81. To fetch the portal name from the url -
    window.location.href.split('/')[3]

    ReplyDelete
  82. while deleting a custom permission, It is showing that referred in a page but not able to find the references.
    Solution: Just edit the page and save it, it should be resolved.

    ReplyDelete
  83. Managed Package:
    Cannot add additional parameters for the global/webservice methods for the new version of the managed package

    ReplyDelete
  84. To get the data type of a field in the visualforce page
    $ObjectType[objName].fields[fld].Type

    ReplyDelete
  85. Opening the hyperlink in new tab within the cosole if it is in cosole -

    https://developer.salesforce.com/forums/?id=9060G000000XfF8QAK

    Make sure to add includescript (script type="text/javascript") as below documentation -
    https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_getenclosingtabid.htm

    ReplyDelete
  86. In line Visualforce Page:
    Issue: On changing the drop down value in UI View (changing division which call a method which redirect to the same page), and edit the view is causing the problem -
    "confirm form re-submission" blank screen in chrome browser.
    Resolution: changing division which call a method which redirect to the same page --> in the redirect url in server use pr.setRedirect(true)

    ReplyDelete
  87. Cannot read property 'call' of undefined with google chart, issue is with the options.

    ReplyDelete

Labels