How to create a fieldset in Apex code?

How to create a fieldset in Apex code?

In the example below, we will use fieldset to display account list on visualforce page. We will use dynamic SOQL query in Apex code. First we need to create a fieldset. Go to Setup > Customize > Accounts > Field Set Click on new. Enter all mandatory fields. Also drag and drop all required fields in fieldset.

How to use dynamic soql query in Apex code?

We will use dynamic SOQL query in Apex code. First we need to create a fieldset. Go to Setup > Customize > Accounts > Field Set Click on new. Enter all mandatory fields. Also drag and drop all required fields in fieldset. We will get following output in visualforce page:

How are reference fields populated in Salesforce apex?

The reference field is only populated as the result of a SOQL or SOSL query (see note). For example, the following Apex code shows how an account and a contact can be associated with one another, and then how the contact can be used to modify a field on the account:

When to use aggregateresult in apex soql?

AggregateResult is a readonly sObject and is only used for query results. It is useful when we need to generate the Report on Large data. There are other aggregate functions as well which you can be used to perform data summary.

How to create a fieldet in Salesforce?

First we need to create a fieldset. Go to Setup > Customize > Accounts > Field Set Click on new. Enter all mandatory fields. Also drag and drop all required fields in fieldset. We will get following output in visualforce page: For more details about using fieldset in visualforce, refer to Fieldset visualforce page salesforce.

How to use fielset in Visualforce Apex code?

By using dynamic SOQL query in Apex and using fielset in visualforce and Apex code. Our code will become dynamic, then we can add, remover or reorder fields in fieldset. By doing so, our code will become dynamic.

What does a field set do in Visualforce?

A field set is a grouping of fields for same object. We can use dynamic bindings to display field sets on our Visualforce pages. Fieldset is very useful when we are working with managed package.

How to insert and update accounts in apex?

First, three Account sObjects are created and added to a list. An insert statement bulk inserts the list of accounts as an argument. Then, the second account record is updated, the billing city is updated, and the update statement is called to persist the change in the database. // Update account Acme2.