12 votes

How to catch internal Salesforce error in APEX?

Internal Server Errors are just that; errors that occur in the runtime environment that are not accounted for. For example, the runtime knows how to express a NullPointerException, but it doesn't know ...
sfdcfox's user avatar
  • 476k
6 votes
Accepted

Visualforce URLFOR parameter binding

If you look at Valid Values for the $Action Global Variable, NewCase is not listed. The correct action is New. Take a look at the Visualforce Developer Guide - Functions. The syntax is {!URLFOR(...
Adrian Larson's user avatar
  • 149k
6 votes
Accepted

Javascript to calculate total at row and column level

The DOM Id values in Visualforce tables include a row number (the :0: in your JavaScript) so your logic needs to incorporate that. The approach that I think works best is to use a CSS class (that has ...
Keith C's user avatar
  • 134k
6 votes
Accepted

Search functionality in Visualforce Page

In theory, yes, but realistically, no. The Visualforce reRender engine causes input elements to lose focus, repeated calls in a short period can cause the view state to become disorganized, ...
sfdcfox's user avatar
  • 476k
5 votes

How to create nth level tree hierarchy structure in salesforce?

Without resorting to client-side rendering, you can do it like this. First, create a Node class to store nodes and their children. public class Node { public String title { get; set; } ...
sfdcfox's user avatar
  • 476k
5 votes

How to extract a number from a string

I prefer using regular expressions. You can replace all non number characters with empty character, and you will have only numbers left. This regex says: any character a-z or A-Z or dash String ...
Vladyslav K's user avatar
  • 2,693
5 votes
Accepted

How to show Columns of Visualforce Page Based on Custom Settings Fields?

Use a Field Set instead. It was designed with this scenario in mind. Working with Field Sets You can use dynamic bindings to display field sets on your Visualforce pages. A field set is a grouping of ...
Adrian Larson's user avatar
  • 149k
5 votes
Accepted

Is it possible to get the label or describe from an SObjectTypeToken?

Controller: public class Test{ public Schema.SObjectType myProperty { get; private set; } public Test(){ myProperty = Schema.getGlobalDescribe().get( 'Account' ); } } <...
Ronnie's user avatar
  • 2,067
4 votes

I have api objectfield name, how can I get the label?

another simple way to display field label from apex, is like this (if the object and field is not to be dynamic) : Schema.SObjectType.Contact.fields.Student__c.getLabel() If it is to be displayed ...
vanessen's user avatar
  • 2,525
4 votes

Get Map values inside vf Component and in apex:repeat

Looking at the provided Component and Controller markup, I believe you are getting the error because you trying to iterate over a string value. Looking at this < apex:repeat value="{!mapkv[key]}"...
manjit5190's user avatar
  • 7,983
4 votes
Accepted

Visualforce | Multi Conditional Block Rendering

Once you are in a Visualforce {! } expression fields are referenced without a further ! (and a ! prefix becomes shorthand for a NOT function). Also the result of the AND function is already a boolean ...
Keith C's user avatar
  • 134k
4 votes
Accepted

Dynamic Describe Result

Referring to blog http://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/ you can get field information using a Describe call. public static Map<String, Schema....
Devendra's user avatar
  • 5,057
4 votes

Visualforce dynamic rendering based on Object Type

The "easiest" way would be to go down the dark, dark road of Dynamic Apex, because Visualforce has a problem binding to non-SObject types dynamically. The only other alternative I can immediately ...
sfdcfox's user avatar
  • 476k
4 votes

Assign Ids dynamically to Apex:inputField

You can't dynamically assign the Visualforce id attribute. You can, however, assign data- attributes or pass through html- attributes. See, for example, Setting Custom HTML Attributes on Visualforce ...
Adrian Larson's user avatar
  • 149k
4 votes
Accepted

How can I dynamically add input fields in visual force on a button click?

This is a very common requirement. First add a Add row button with ypur table <apex:commandButton value="Add More" action="{!addNewRow}" rerender="frm" Status="status" immediate="true" /> and ...
Tushar Sharma's user avatar
3 votes
Accepted

Getting a VF component dynamically by name in Apex

After exhaustively searching around this topic I finally found what appears to be the answer: Loading a custom component into a Visualforce page dynamically Dynamic components on a Visualforce page ...
Mossi's user avatar
  • 3,886
3 votes
Accepted

URLFOR/Component.Apex.OutputText in Unit Test causing Internal Server Error?

The problem is that unit testing does not currently invoke an entire Visualforce context. I have received a story number (with safe harbor attached) that this will be considered for a future version. ...
sfdcfox's user avatar
  • 476k
3 votes
Accepted

" Error occurred while loading a Visualforce page " in Portal Site,

@SFDC_Igle you can try one thing. In standard exception Page you will find one line as shown below <apex:param value="{!error.messages}" /> which you should change to <apex:param value="{!...
Tushar Sharma's user avatar
3 votes

How to refresh the parent page after a Save action in a Visualforce page embedded in a page layout?

@Rao's answer works for me in Classic as of Winter '17 release. But if you have a form the user is submitting and you get back errors you may not want the page to have opened in the parent frame, ...
Doug Ayers's user avatar
  • 4,156
3 votes
Accepted

Disable selectList after selection is made

You can try one thing. Check if recordType not null then then hide this field <apex:outputText value="{!recordType}" rendered="{!recordType != null || recordType != ''}"/ > <apex:...
Tushar Sharma's user avatar
3 votes
Accepted

How to hide or show (<DIV>) items dynamically in a VF Component?

You need to split your Previous/Next navigation into uniquely addressable elements rather than grouping them together, and, ideally, use an <apex:outputPanel> or <apex:pageBlock> or even &...
Jonathan Hersh's user avatar
3 votes

Creating VF page by using Salesforce Tooling API . JSON_PARSER_ERROR

You don't need to escape the double quotes because Apex uses a single quote as a string delimiter. The best way to create JSON is not by concatenating the string yourself but letting JSON.serialize ...
Keith C's user avatar
  • 134k
3 votes

Set Visualforce Picklist value from custom controller

You have a string variable PeriodCode and a method getPeriodCode of return type List<SelectOption>. This is confusing and not a good practice. I just changed the String variable name and it ...
abdn's user avatar
  • 525
3 votes
Accepted

Dynamic Select Option in Remote Objects Visualforce. This page is not record-specific

You can use remoting for this purpose. Here's a generic page that loads the record types for Account (replace with your desired object): <apex:page > <apex:remoteObjects jsNamespace="...
sfdcfox's user avatar
  • 476k
3 votes
Accepted

Visualforce Email Templates Dynamic Subject Child Object

You can't access the child that way, unfortunately. If the credit review is more of a 1:1 relationship, I'd recommend that you create a lookup field on the opportunity and populate it with the child ...
sfdcfox's user avatar
  • 476k
3 votes
Accepted

SLDS in Visual Force - How to render a conditional div?

Use apex:outputText: <apex:outputText rendered="{!someCondition}"> <div class="slds-grid slds-wrap slds-gutters"> ... </div> </apex:outputText> Or, you can add in ...
sfdcfox's user avatar
  • 476k
3 votes

Hard coded images - How to convert

You can set the url dynamically by using the getSalesforceBaseUrl() method in the URL class. This will always get the current instance for the org so you don't have to manually update it each time. ...
Brian Simpson's user avatar
3 votes
Accepted

How to keep components out of the Visualforce view state when they are not needed?

I've gone with generating the components in Apex and hooking them into the page via an apex:dynamicComponent. This solves my view state problem: each unused extension point now consumes 30 bytes (an ...
Keith C's user avatar
  • 134k
3 votes

List view button without standard controller

No. The best you can do is move the core markup you want to not duplicate into a Visualforce Component instead. You need one top level Visualforce Page for each object you wish to support, end of ...
Adrian Larson's user avatar
  • 149k
3 votes
Accepted

Open model/dialog/VF Page/LWC Component from Salesforce trigger

No, you can't do this. Triggers are backend functionality only and may execute in contexts that have no associated user interface session You must implement this type of functionality on the front end ...
David Reed's user avatar
  • 91.7k

Only top scored, non community-wiki answers of a minimum length are eligible