Thursday, 8 July 2021

Salesforce Configuration VS. Salesforce Customization

If a business decides to utilize a Salesforce solution, then they can expect it to meet all business requirements fully. The Salesforce platform is something that can provide business the functionality one might expect because it is configurable as well as customizable. Many businesses believe that Salesforce Configuration and customization are the same. However, these are actually quite different from each other.

The statistics tell us that more than 90% of the businesses during the Salesforce CRM development and customization have to deal with both configuration and customization. And the platform itself is designed to handle these things perfectly.

Difference between Configuration and Customization

When it comes to configuration, you deal with the items already available on the platform; you select whatever you need. However, if you need to perform customization, you have to handle the code to make the solution work as required. If you have to move to customization, it means that the available resources are not enough.

Salesforce Configuration

Salesforce Configuration is configuring your needs to the system without changing much of the basic structure. The configuration is less complicated, due to the availability of all the features and functions in the Salesforce environment. So, there should be fewer issues while implementing your business requirements. For that, you need to clearly understand what the features mean and how to handle them.

Features of Salesforce Configuration:

  • Configuration in Salesforce means offering user-defined values that will empower certain features/modules to start operating.
  • Configuration can allow you to work with the Salesforce Admin panel to alter switches and setups in the programs.
  • Salesforce Configuration helps to implement business requirements using Salesforce OOTB functionality.
  • You can add new Objects and fields, modules, workflows, surveys, and reports by altering settings in the Admin panel.
  • Customers can get what they expect by configuring and acquiring a pre-defined application of Salesforce.
  • It supports some inbuilt features like, Email-to-Case, Web-to-Case, Email-to-Lead, etc.

Salesforce Configuration includes:

  • Adding Objects/Fields
  • Adding tabs/apps
  • Create new profiles
  • Setting Permissions
  • Work with reports and workflows
  • Create email templates
  • Validation rules
  • Create page layouts or record types
  • Integrating Email Client
  • Create apps for AppExchange as well as Add some applications from AppExchange

Salesforce Customization

Customization can be stated as a step ahead of Salesforce configuration. Customization is required for cases where configuration doesn’t serve the purpose. Salesforce Customization relates to the custom development of code for creating tailored features and functionalities. If you have to move to customization, it means that the available resources are not enough, and you have to handle the code to make the solution work as required.

Features of Salesforce customization:

  • It helps in developing features/functions that aren’t available as a part of the Standard Salesforce Solution.
  • It helps to achieve certain actions that aren’t covered in OOTB configuration and requires some custom coding.
  • Customization allows the addition of triggers on the object to perform a few actions.
  • Salesforce Customization can be considered complex and involves giving attention to user adoption.
  • Once the Configuration is done properly, then Customization is used and brings fruitful results.

Salesforce Customization includes:

  • Work with Apex classes or triggers
  • Work with Visualforce and its components
  • Use CSS to change how the pages look
  • Integrate the solution with the third-party solutions
  • Use JavaScript to add additional features and capabilities
  • Create Lightning components
  • Build custom partner portals
  • Optimize the design and functionality

Summary:

Customization and Configuration are the most essential and demanded factors if you want to cover all your business’ needs. So, whatever you choose, make sure you get everything done with the help of a knowledgeable and experienced Salesforce implementation partner.

If you have any questions you can reach out our Salesforce Consulting team here.

Thursday, 17 June 2021

Salesforce Custom Metadata Type

In Salesforce Custom Metadata type is similar to creating custom object or custom setting. A custom metadata type's records are metadata, not data, in and of themselves. In contrast to Custom Settings, where only metadata is eligible for migration, Custom Metadata Type and its records can be migrated from one org to another during deployment. Custom Metadata is usually deployable, package-able, customizable, and upgradeable. The key benefit of using Custom Metadata is that it does not count against the SOQL query limit for each APEX transaction.

Custom metadata types can be used for


  • Mappings— Make connections between objects, such as a custom metadata type that allocates cities, states, or provinces to specific countries & regions. 
  • Business rules— Custom functionality can be combined with configuration records. To route payments to the correct destination, use custom information types and Apex code.
  • Master data— Assume your organization utilizes a basic accounting system. Create a special metadata type for custom charges such as customs and VAT rates. Subscriber orgs can refer to the master data if this type is included as part of an extension package. 
  • Whitelists— Keep track of lists like approved contributors and pre-approved vendors. 
  • Secrets— Protected custom metadata types within a package can be used to store information such as API keys. 

Field Manageability


Field manageability is used to manage custom fields when they are created under the Custom Metadata Type. Custom metadata type supports the following custom field types: 
  • Metadata Relationship 
  • Checkbox
  • Date
  • Date and Time 
  • Email
  • Number
  • Percent
  • Phone
  • Picklist
  • Text
  • Text Area 
  • URL

Access Custom Metadata Type Records


There are new ways to access Custom Metadata Types in the Salesforce Spring-21 pre-release orgs and similar to those for Custom Settings. It is no longer necessary to query them using SOQL, and the contribution to the Query Rows limit is reduced. To access information from custom metadata type records faster, use the Apex getAll(), getInstance(recordId), getInstance(qualifiedApiName), and getInstance(developerName) methods. These methods don't use the SOQL engine and return the sObject information from the call directly.

1.Access the Custom Metadata Type records before Spring 21.

2.Access the Custom Metadata Type records after Spring 21.

A. getAll() to get Custom Metadata Type Records.

The following example uses the getAll() method. The custom metadata type named Ticket has a field called TicketType 

B. getInstance() to get specific Custom Metadata Type Record.

What about if you don’t need to get all records and need to access only a single record? In that case, you can use the getInstance() method. 

Advantages of Custom Metadata:

  • It's possible to distribute metadata! There will be no more time-consuming post-deployment configuration, as there will be with custom settings. To create your default custom setting records, you don't need to develop Apex classes.
  • Change sets or the force.com migration tool can also be used to deploy custom metadata records with metadata type definitions (ANT). The records in custom settings are uploaded after the definition of the custom setting is deployed. 
  • ListViews, Page Layouts, and Validation Rules can be created on the Custom Metadata Types.
  • Metadata Relationships are a thing of beauty! Lookups between Custom Metadata objects are possible. You may also perform an Object Definition lookup.
  • With custom metadata types, you can issue unlimited Salesforce Object Query Language (SOQL) queries for each Apex transaction. 
  • Custom metadata type is visible in test class without using “SeeAllData”. 
  • Custom Settings has the same permissions to edit records and configure the system. The “Configure Application” permission allows you to do both. You can edit records with Custom Metadata's "Configure Application," but you'll need "Author Apex" to update the configuration.

Limitations


The following are the limitations of Custom Metadata Type:
  • Custom metadata records cannot exceed the size of 10MB.
  • It does not support formula field data type.
  • It cannot be updated through Apex. The only way to edit custom metadata types is by leveraging metadata API
  • 100 custom metadata types can be created per salesforce org. 
  • We can create only 100 fields per custom metadata type. 
  • Global picklists are not supported. 

Summary


By creating custom metadata, we can create a static set of data and reuse it in our applications, triggers, apex class, test class, Aura components, etc. Click here for more details. 

If you have any questions you can reach out our Salesforce Consulting team here.

Thursday, 10 June 2021

How to use apex:actionFunction in a Salesforce Visualforce Page?


SCENARIO


While working on one of the requirements for a banking sector project for a customer based in San Diego, California there was a requirement to update selected record in Visual Force Page.

 

Clicking on Update button, we need to pass the updated values from inputs of Visualforce page to apex class so that is that DML operations can be performed.

 

SOLUTION


To fulfil the requirement, we have used <apex:actionFuntion> tag of Visualforce page. By using this tag, we can call apex controller method from java script code using an AJAX request.  


To set field values directly from VF page, we have used <apex:param> with <apex:actionFunction> and added this keyword in the assignedTo attribute of <apex:param>. 

 

Below is a sample code for reference. Here we are updating Account Name using <apex:actionFunction>.

  1. On click of Update button, JS function will get the updated value of Account Name and pass it to the param of actionFunction. 
  2. The actionFunction first sets the value of the variable and then invokes the method of apex class to update the account record. 

ActionFunction.vfp 

<apex:page controller="actionFunctionExampleController" sidebar="false" showHeader="false">
    <div style="margin : 20px;">
        
        <apex:form id="accountForm">
            <apex:actionFunction action="{!updateAccount}" name="updateAccountAF" reRender="dataTable">
                <apex:param name="accountName" assignTo="{!this.account.Name}" value="" />
            </apex:actionFunction>
            
            <apex:outputpanel >
                <label>Name :</label>
                <apex:inputField id="accountName" value="{!account.Name}"/>
                <apex:commandButton value="Update" onclick="GetAccountName(); return false;" />
            </apex:outputpanel>
        </apex:form>
        
        <div style="margin:20px 0px;">
            <apex:dataTable value="{!account}" var="acc" id="dataTable" border="1" width="50%">
                <apex:column value="{!acc.Name}" headerValue="Name"/>
                <apex:column value="{!acc.Type}" headerValue="Type"/>
                <apex:column value="{!acc.AccountNumber}" headerValue="Account Number"/>            
                <apex:column value="{!acc.Industry}" headerValue="Industry"/>
            </apex:dataTable>
        </div>
    </div>
    
    <script type="text/javascript">
        function GetAccountName(){
            var accountName = document.getElementById("{!$Component.accountForm.accountName}").value;        
            updateAccountAF(accountName);
        }
    </script>
    
</apex:page>


ActionFunctionController.apxc 

public class actionFunctionExampleController {
    
    public Account account {get;set;}
        
    public actionFunctionExampleController(){
        Id accountId  = ApexPages.CurrentPage().getparameters().get('id');
        account = [select id, Name, AccountNumber, Type, Industry from Account where id =: accountId ];
    }
    
    public void updateAccount(){
        update account;
    }
}


NOTE: 


Also, we can get the values of <apex:param> by using the below code in apex class. For that, we don't need to write assignedTo attribute in VF page. 


Apexpages.currentPage().getParameters.get(paramName);



FACTS TO CONSIDER:

  • An <apex:actionFunction> component must be a child of an <apex:form> component.
  • Since the caller and <apex:actionFunction> are bound based on parameter order, make sure the caller's argument list matches the order of <apex:param>. 
  • For API version 23 or later, you cannot use <apex:actionFunction> inside an iteration component like, <apex:pageBlockTable>, <apex:repeat>, and so on. 

 

OUTPUT



If you have any questions you can reach out our Salesforce Consulting team here.