Salesforce Interview Questions with Answers Part 45

1. Performance Testing in Salesforce

Before you can performance test in your sandbox environment, you must first create a test plan and submit it to salesforce.com Customer Support.

http://www.infallibletechie.com/2017/07/performance-testing-in-salesforce.html

2. PK Chunking in Salesforce

http://www.infallibletechie.com/2017/07/pk-chunking-in-salesforce.html

3. Divisions in Salesforce

http://www.infallibletechie.com/2017/07/divisions-in-salesforce.html

4. Community user unable view articles?

a. Check the Article type access to community user profile.
b. Make sure articles are shared to customer or partner or just Internal App.

5. How to create Global Picklist Value Sets from existing pick list field in Salesforce?

http://www.infallibletechie.com/2017/08/how-to-create-global-picklist-value.html

6. Default Values formula in Picklist Fields Salesforce

http://www.infallibletechie.com/2017/08/default-values-formula-in-picklist.html

7. Session-Based Permission Sets in Salesforce

http://www.infallibletechie.com/2017/08/session-based-permission-sets-in.html

8. Chatter Streams in Salesforce

http://www.infallibletechie.com/2017/08/chatter-streams-in-salesforce.html

9. Grant Access Using Hierarchies in Public Group in Salesforce

http://www.infallibletechie.com/2017/10/grant-access-using-hierarchies-in.html

10. Dynamic Apex

http://www.infallibletechie.com/2012/10/dyanamic-apex.html

11. JavaScript in Strict Mode

http://www.infallibletechie.com/2017/10/javascript-in-strict-mode.html

12. Are CRUD and FLS considered in Lightning component?

No. Visualforce enforces the active user’s CRUD and FLS permissions when a page renders a Salesforce object. Lightning doesn’t do any client-side authorization, so it doesn’t respect these permissions. The following code shows data to all users, even those who aren’t authorized to see it.

<b>Hello <i>{!v.User.FirstName}</i>.</b>

13. How to use JAVASCRIPT file stored in Static Resources in custom Lightning component?

http://www.infallibletechie.com/2017/10/how-to-use-javascript-file-stored-in.html

14. {! } and {# } delimiters in Salesforce Lightning

http://www.infallibletechie.com/2017/10/and-delimiters-in-salesforce-lightning.html

15. force:createRecord in Salesforce Lightning 

http://www.infallibletechie.com/2017/11/forcecreaterecord-example-in-salesforce.html

16. How does Platform events trigger fire?

Unlike triggers on standard or custom objects, triggers on platform events don’t execute in the same Apex transaction as the one that published the event. The trigger runs asynchronously in its own process under the Automated Process entity. As a result, there might be a delay between when an event is published and when the trigger processes the event. Also, debug logs corresponding to the trigger execution are created by Automated Process. System fields, such as CreatedById and LastModifiedById, reference the Automated Process entity.

17.  Is it possible to schedule a dynamic dashboard in Salesforce?

In Salesforce, it is not possible to schedule a dynamic dashboard.

18. What is the use of static variable? 

When you declare a method or variable as static, it’s initialized only once when a class is loaded. Static variables aren’t transmitted as part of the view state for a Visualforce page. Static variables are only static within the scope of the request. They are not static across the server, or across the entire organization.

19. <force:recordView> Types?

<force:recordView recordId="a02D0000006V8Ov" type="MINI"/> - Uses Compact Layout

<force:recordView recordId="a02D0000006V8Ov" type="FULL"/> - Uses page layout

Cheers!!!

force:navigateToURL example in Salesforce Lightning

AccountList.cmp:

<aura:component controller="AccountListController"
                implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" >
    
    <aura:attribute type="Account[]" name="acctList"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title_caps">
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Account Name</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Industry</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="Action">Actions</div>
                </th>
            </tr>
        </thead>
        <tbody>
         <aura:iteration items="{!v.acctList}" var="a">
                <tr>
                    <td data-label="Account Name">
                        <div class="slds-truncate" title="">{!a.Name}</div>
                    </td>
                    <td data-label="Industry">
                        <div class="slds-truncate" title="">{!a.Industry}</div>
                    </td>
                    <td>
                     <button class="slds-button slds-button_brand" onclick="{!c.editAccount}" id="{!a.Id}">Edit</button>
                     <button class="slds-button slds-button_brand" onclick="{!c.viewAccount}" id="{!a.Id}">View</button>
                    </td>                        
                </tr>
            </aura:iteration>
        </tbody>
    </table>
    
</aura:component>

AccountListController.js

({
    fetchAccounts : function(component, event, helper) {
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    editAccount : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": event.target.id
       });
       editRecordEvent.fire();
    },
    viewAccount : function(component, event, helper) {
        var viewRecordEvent = $A.get("e.force:navigateToURL");
        viewRecordEvent.setParams({
             "url": "/" + event.target.id
       });
       viewRecordEvent.fire();
    }
})

Apex Class:

public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ];
    }
    
}

Output:


Once the user clicks View button, it will take them to the detail page of the account record.

Cheers!!!

Skype for Salesforce

Enable Skype for Salesforce in your org so your sales and service reps can chat and see who’s online without leaving Salesforce.

Skype for Salesforce lets your users connect their Skype for Business accounts to Salesforce. Skype for Salesforce lets them send chat messages with other Skype for Business users from within the Salesforce app.

Available in: Lightning Experience

1. Go to Skype for Salesforce.


2. Enable Skype Chat.


3. Create a permission set with Skype Conversation permission enabled.


4. Check the banner for Connect Your Skype Account and click the link.


5. Click Connect Office 365.


6. Enter your Office 365 login credentials.

Cheers!!!

force:editRecord example in Salesforce Lightning

AccountList.cmp:

<aura:component controller="AccountListController"
                implements="flexipage:availableForAllPageTypes,lightning:actionOverride,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:appHostable" >
    
    <aura:attribute type="Account[]" name="acctList"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title_caps">
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Account Name</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Industry</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="Action">Actions</div>
                </th>
            </tr>
        </thead>
        <tbody>
        <aura:iteration items="{!v.acctList}" var="a">
                <tr>
                    <td data-label="Account Name">
                        <div class="slds-truncate" title="">{!a.Name}</div>
                    </td>
                    <td data-label="Industry">
                        <div class="slds-truncate" title="">{!a.Industry}</div>
                    </td>
                    <td>
                    <button class="slds-button slds-button_brand" onclick="{!c.editAccount}" id="{!a.Id}">Edit</button>
                    </td>                        
                </tr>
            </aura:iteration>
        </tbody>
    </table>
    
</aura:component>

AccountListController.js

({
    fetchAccounts : function(component, event, helper) {
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
    editAccount : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": event.target.id
       });
       editRecordEvent.fire();
    }
})

Apex Class:

public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ];
    }
    
}

Output:



Cheers!!!

aura:iteration example in Salesforce Lightning Component

Sample App:

<aura:application extends="force:slds">
    <c:AccountList />
</aura:application>

AccountList.cmp:

<aura:component controller="AccountListController">
    
    <aura:attribute type="Account[]" name="acctList"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.fetchAccounts}"/>
    
    <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title_caps">
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Account Name</div>
                </th>
                <th scope="col">
                    <div class="slds-truncate" title="Account Name">Industry</div>
                </th>
            </tr>
        </thead>
        <tbody>
        <aura:iteration items="{!v.acctList}" var="a">
                <tr>
                    <td data-label="Account Name">
                        <div class="slds-truncate" title="">{!a.Name}</div>
                    </td>
                    <td data-label="Industry">
                        <div class="slds-truncate" title="">{!a.Industry}</div>
                    </td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
    
</aura:component>

AccountListController.js

({
    fetchAccounts : function(component, event, helper) {
        var action = component.get("c.fetchAccts");
        action.setParams({
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.acctList", response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    }
})

Apex Class:

public class AccountListController {

    @AuraEnabled
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ];
    }
    
}

Output:


Cheers!!!

What is the use of nextStartDate?

Starting from the specified target date, returns the next date when business hours are open. If the specified target date falls within business hours, this target date is returned.

Sample Code:
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE IsDefault = true];
Datetime nextStart = BusinessHours.nextStartDate(bh.id, system.today());
system.debug('Next Start Date is ' + nextStart);

If you execute the above code within the business hours(example if the business hours is 9 am to 6 pm and execute within the time frame), then it will return today's date.

If you execute the above code outside the business hours(example if the business hours is 9 am to 6 pm and execute outside the time frame), then it will return next open business date.

Cheers!!!

How to get the current hour in the local time zone of the context user using apex in Salesforce?

hour() returns the hour component of a Datetime in the local time zone of the context user.

Sample Code:

trigger CaseTrigger on Case (before insert) {
    
    Boolean tomorrowTargetBool = system.now().hour() >= 12 ? true : false;
    for ( Case c : trigger.new ) {
        if ( tomorrowTargetBool ) 
            c.Target_Date__c = system.today() + 1;
    }
    
}

In the above example, if the case is created after 12 PM, the target date field will be next day.

Cheers!!!

How to avoid or reduce SOQLs in Salesforce?

1. Do not use SOQL inside the for loop.

2. User UserInfo wherever possible - http://www.infallibletechie.com/2016/01/how-to-get-username-of-user-using-apex.html.

3. Use Custom Settings for hard coding Report Folder or Dashboard Folder ids, Email Templates ids, Public Group ids, Field ids, etc.

4. Use @future methods or queueable interface.

http://www.infallibletechie.com/2012/08/future-annotation-in-salesforce.html

http://www.infallibletechie.com/2016/08/queueable-apex.html

5. Avoid triggers from firing again and again - http://www.infallibletechie.com/2014/05/how-to-avoid-recursive-trigger-in.html.

6. Use trigger instead of workflow rules and process builders since they are not bulkified.

7. Use schema instead of query to get record type, etc - http://www.infallibletechie.com/2014/03/how-to-get-recordtypeid-using-record.html.

Cheers!!!

Salesforce Interview Questions with Answers Part 49

1. What is a Mashup?

A mashup is a Web page or application that combines data or functionality from two ore more sources to create a new service.

http://www.infallibletechie.com/2018/01/what-is-mashup.html

2. What is JSON?

JSON stands for Java Script Object Notation. It is a lightweight and text-based format. Supports with UTF-8 and date-time information in ISO8601 format. It uses string value pairs for storing data.

http://www.infallibletechie.com/2018/01/what-is-json.html

3. Force.com Streaming API

Use Streaming API to receive notifications for changes to Salesforce data that match a SOQL query you define, in a secure and scalable way.

http://www.infallibletechie.com/2015/03/forcecom-streaming-api.html

4. Salesforce APIs and supported formats

http://www.infallibletechie.com/2018/01/salesforce-apis-and-supported-formats.html

5. What is a PushTopic?

A PushTopic is record that

1. Defines a channel.

2. Determines what events will cause a notification. Event is a modification of a field while creating, updating, deleting or undeleting a record.

3. Describes the data the notification will contain.


Used in Streaming API.

http://www.infallibletechie.com/2018/01/what-is-pushtopic.html

6. What is WSDL?

Web Services Description Language is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.

http://www.infallibletechie.com/2018/01/what-is-wsdl.html

7. SOAP API Methods using WSDL from Salesforce

http://www.infallibletechie.com/2018/01/soap-api-methods-using-wsdl-from.html

8. Difference between SOAP and REST APIs

http://www.infallibletechie.com/2014/03/blog-post.html

9. HTTP Methods available in Salesforce

http://www.infallibletechie.com/2018/01/http-methods-available-in-salesforce.html

10. What is the use of done attribute in Salesforce REST API response?

http://www.infallibletechie.com/2018/01/what-is-use-of-done-attribute-in.html

11. What is the Chatter REST API?

http://www.infallibletechie.com/2018/01/what-is-chatter-rest-api.html

12. Lock Contention

http://www.infallibletechie.com/2018/01/lock-contention.html

13. How to limit maximum number of characters that can be typed into ui:inputText and other input fields in Lightning Components?

http://www.infallibletechie.com/2018/01/how-to-limit-maximum-number-of.html

14. Cross-Org Adapter for Salesforce Connect

https://help.salesforce.com/articleView?id=xorg_adapter_about.htm&type=5

15. Continuation Class

Use the Continuation class to make callouts asynchronously to a SOAP or REST Web service.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Continuation.htm#apex_class_System_Continuation

16. How to avoid or reduce SOQLs in Salesforce?

http://www.infallibletechie.com/2018/02/how-to-avoid-or-reduce-soqls-in.html

17. A custom object contains some records, now my requirement is to create field in this object with master-detail relationship. Can we create master-detail relationship in this case? 

No, directly we cannot create master-detail relationship if the custom object contains existing records.

Cheers!!!