aura:if tag Lightning component example

aura:if tag Lightning component example

aura:if tag Lightning component example

aura if renders the content within the tag if the isTrue attribute evaluates to true. The framework evaluates the isTrue expression and instantiates components either in its body or else attribute.

Difference between aura if and aura renderIf

aura:if instantiates the components in either its body or the else attribute, but not both. aura:renderIf instantiates both the components in its body and the else attribute, but only renders one. If the state of isTrue changes, aura:if has to first instantiate the components for the other state and then render them. We recommend using aura:if instead of aura:renderIf to improve performance.

Example of using aura if

    <aura:attribute name="variable1" type="boolean" default="true"/>
    <aura:attribute name="variable2" type="boolean" default="false"/>
    <aura:attribute name="variable3" type="boolean" default="true"/>
    <aura:attribute name="variable4" type="boolean" default="false"/>
    
    <!--Example of aura:if-->
    <aura:if isTrue="{!v.variable1}">
        <div style="background-color:LightBlue">
    		This should be displayed as variable1 is true
        </div>
    </aura:if>

Example of aura if with aura set else attribute

Assuming that we have same 4 attributes available.

    <!--Example of aura:if with aura:set else attribute-->
    <aura:if isTrue="{!v.variable2}">
        <div style="background-color:LightBlue">
    		This should not be displayed as variable2 is false so else part will execute.
        </div>
        <aura:set attribute="else">
            <div style="background-color:LightBlue">
        		This should be displayed as if condition is not satisfied.
            </div>
    	</aura:set>
    </aura:if>

Example of using and condition with aura:if

    <!--Example of using AND condition with aura:if-->
    <aura:if isTrue="{!and(v.variable1, v.variable2)}" >
        <div style="background-color:LightBlue">
        	and Example. As variable1 is true and variable2 is false so nothing will be displayed.
        </div>
    </aura:if>

    <aura:if isTrue="{!and(v.variable1, v.variable3)}" >
        <div style="background-color:LightBlue">
        	and Example. As variable1 is true and variable3 is true so it will be displayed.
        </div>
    </aura:if>

Example of using or condition with aura if

    <!--Example of using OR condition with aura:if-->
    <aura:if isTrue="{!or(v.variable1, v.variable2)}" >
        <div style="background-color:LightBlue">
        	or Example. As variable1 is true and variable2 is false so it will be displayed.
        </div>
    </aura:if>
    <aura:if isTrue="{!or(v.variable2, v.variable4)}" >
        <div style="background-color:LightBlue">
        	or Example. As variable2 is false and variable4 is false so it will not be displayed.
        </div>
    </aura:if>

aura if multiple conditions

   <!--aura:if with complex or and condition-->
    <aura:if  isTrue="{!or(and(v.variable1, v.variable3) , v.variable2 ) }" >
        <div style="background-color:LightBlue">
            complex or and example. It will showup as variable1 is true, variable3 is true and variable2 is false
        </div>
    </aura:if>

aura if complete component example code

<aura:component >
    <aura:attribute name="variable1" type="boolean" default="true"/>
    <aura:attribute name="variable2" type="boolean" default="false"/>
    <aura:attribute name="variable3" type="boolean" default="true"/>
    <aura:attribute name="variable4" type="boolean" default="false"/>
    
    <!--Example of aura:if-->
    <aura:if isTrue="{!v.variable1}">
        <div style="background-color:LightBlue">
    		This should be displayed as variable1 is true
        </div>
    </aura:if>
    
    <!--Example of aura:if with aura:set else attribute-->
    <aura:if isTrue="{!v.variable2}">
        <div style="background-color:LightBlue">
    		This should not be displayed as variable2 is false so else part will execute.
        </div>
        <aura:set attribute="else">
            <div style="background-color:LightBlue">
        		This should be displayed as if condition is not satisfied.
            </div>
    	</aura:set>
    </aura:if>
    
    <!--Example of using AND condition with aura:if-->
    <aura:if isTrue="{!and(v.variable1, v.variable2)}" >
        <div style="background-color:LightBlue">
        	and Example. As variable1 is true and variable2 is false so nothing will be displayed.
        </div>
    </aura:if>
    
    <aura:if isTrue="{!and(v.variable1, v.variable3)}" >
        <div style="background-color:LightBlue">
        	and Example. As variable1 is true and variable3 is true so it will be displayed.
        </div>
    </aura:if>
    
    <!--Example of using OR condition with aura:if-->
    <aura:if isTrue="{!or(v.variable1, v.variable2)}" >
        <div style="background-color:LightBlue">
        	or Example. As variable1 is true and variable2 is false so it will be displayed.
        </div>
    </aura:if>
    <aura:if isTrue="{!or(v.variable2, v.variable4)}" >
        <div style="background-color:LightBlue">
        	or Example. As variable2 is false and variable4 is false so it will not be displayed.
        </div>
    </aura:if>
    
    <!--aura:if with complex or and condition-->
    <aura:if  isTrue="{!or(and(v.variable1, v.variable3) , v.variable2 ) }" >
        <div style="background-color:LightBlue">
            complex or and example. It will showup as variable1 is true, variable3 is true and variable2 is false
        </div>
    </aura:if>
    
</aura:component>

Sample App for LightningComponentAuraIfExample

<aura:application >
    <c:LightningComponentAuraIfExample/>
</aura:application>

aura if output will be

aura if tag Lightning component example output

aura if tag Lightning component example output

For more detail please refer below official link

Salesforce Lightning Interview Questions

Happy Coding 🙂

Permanent link to this article: http://www.sfdcpoint.com/salesforce/auraif-tag-lightning-component-example/

apex random number Salesforce

apex random number Salesforce

apex random number Salesforce

Many time we have requirement to generate random number in Apex. It can be achieved using Math.random() function. This method return a positive Double that is greater than or equal to 0.0 and less than 1.0.

This method only returns number between 0.0 and 1.0. Now its important how we can use this method to generate different variation of random number that we need based on our requirements. Lets see some examples of getting random number.

Get random number between 0 and 10 Apex

Integer randomNumber = Integer.valueof((Math.random() * 10));
System.debug('randomNumber  is'+randomNumber);

Get random number between 0 and 100 Apex

Integer randomNumber = Integer.valueof((Math.random() * 100));
System.debug('randomNumber is'+randomNumber);

Get random Boolean value Apex

Integer randomNumber = Integer.valueof((math.random() * 10));
Boolean randomBoolean = Math.mod(randomNumber,2) == 0 ? true : false;
System.debug('randomBoolean is'+randomBoolean);

Get random String from list of strings Apex

List<String> availableValues = new List<String>{'Red','Green','Blue','White','Black'};
Integer listSize = availableValues.size() - 1;
Integer randomNumber = Integer.valueof((Math.random() * listSize));
String randomString= availableValues[randomNumber];
System.debug('randomString is'+randomString);

 

 

Permanent link to this article: http://www.sfdcpoint.com/salesforce/apex-random-number-salesforce/

Delete Lightning Component in Salesforce

Delete Lightning Component in Salesforce

Delete Lightning Component in Salesforce is very easy. If we don’t want to use IDE like sublime or Eclipse then we can use developer console.

  1. Open Developer Console
  2. Open Your lightning component from File -> Open Lightning Resource
  3. Click on File Delete or use shortcut Ctrl+Delete
Delete Lightning Component in Salesforce

Delete Lightning Component in Salesforce

 

Salesforce Lightning Interview Questions

Lightning Component Library

Permanent link to this article: http://www.sfdcpoint.com/salesforce/delete-lightning-component-in-salesforce/

salesforce order of execution

salesforce order of execution

What is salesforce order of execution?

What is order of execution in salesforce?

salesforce order of execution

When you save a record with an insertupdate, or upsert statement, Salesforce performs the following events in order.

Before Salesforce executes these events on the server, the browser runs JavaScript validation if the record contains any dependent picklist fields. The validation limits each dependent picklist field to its available values. No other validation occurs on the client side.

Salesforce order of execution

Salesforce order of execution

 

Here is order of execution in salesforce

  • The original record is loaded from the database.
  • System Validation Rules.
  • Executes all before triggers.
  • Custom Validation rules.
  • Executes duplicate rules.
  • Saves the record to the database, but doesn’t commit yet.
  • Executes all after triggers.
  • Executes assignment rules.
  • Executes auto-response rules.
  • Executes workflow rules.
  • If there are workflow field updates, updates the record again.
  • If the record was updated with workflow field updates, fires before and after triggers one more time. Custom validation rules, duplicate rules, and escalation rules are not run again.
  • Executes processes and flows launched via processes and flow trigger workflow actions.
  • Executes escalation rules.
  • Executes entitlement rules.
  • If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure.
  • If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure.
  • Executes Criteria Based Sharing evaluation.
  • Commits all DML operations to the database.
  • Executes post-commit logic, such as sending email.

 

Here is order of execution in salesforce in more detail:

On the salesforce server,

  1. Loads the original record from the database or initializes the record for an upsert statement.
  2. Loads the new record field values from the request and overwrites the old values.

    If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:

    • Compliance with layout-specific rules
    • Required values at the layout level and field-definition level
    • Valid field formats
    • Maximum field length

    When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Before executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself.

    Salesforce runs user-defined validation rules if multiline items were created, such as quote line items and opportunity line items.

  3. Executes all before triggers.
  4. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn’t run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.
  5. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses the block action, the record is not saved and no further steps, such as after triggers and workflow rules, are taken.
  6. Saves the record to the database, but doesn’t commit yet.
  7. Executes all after triggers.
  8. Executes assignment rules.
  9. Executes auto-response rules.
  10. Executes workflow rules.
  11. If there are workflow field updates, updates the record again.
  12. If the record was updated with workflow field updates, fires before update triggers and after update trigger one more time (and only one more time), in addition to standard validations. Custom validation rules, duplicate rules, and escalation rules are not run again.
  13. Executes processes and flows launched via processes and flow trigger workflow actions.( process builder)

    When a process or flow executes a DML operation, the affected record goes through the save procedure.

  14. Executes escalation rules.
  15. Executes entitlement rules.
  16. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure.
  17. If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure.
  18. Executes Criteria Based Sharing evaluation.
  19. Commits all DML operations to the database.
  20. Executes post-commit logic, such as sending email.

Additional Considerations

Note the following when working with triggers.

The order of execution isn’t guaranteed when having multiple triggers for the same object due to the same event. For example, if you have two before insert triggers for Case, and a new Case record is inserted that fires the two triggers, the order in which these triggers fire isn’t guaranteed.

Please refer to below official link for salesforce order of execution:

Trigger and Order of Execution

For interview questions related to trigger, refer to below link:

Salesforce Interview Questions on Triggers

Permanent link to this article: http://www.sfdcpoint.com/salesforce/salesforce-order-of-execution/

Trigger context variables in salesforce

Trigger context variables in salesforce

What are Trigger context variables in salesforce?

Trigger context variables in salesforce

All triggers define implicit variables that allow developers to access run-time context. These variables are contained in the System.Trigger class.

Following are the context variable available in triggers. Please note variable availability in trigger varies according to the type of trigger events.

Here is List of Trigger Context Variables

  • isExecuting: Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call.
  • isInsert: Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API.
  • isUpdate: Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.
  • isDelete: Returns true if this trigger was fired due to a delete operation, from the Salesforce user interface, Apex, or the API.
  • isBefore: Returns true if this trigger was fired before any record was saved.
  • isAfter: Returns true if this trigger was fired after all records were saved.
  • isUndelete: Returns true if this trigger was fired after a record is recovered from the Recycle Bin (that is, after an undelete operation from the Salesforce user interface, Apex, or the API.)
  • new: Returns a list of the new versions of the sObject records. This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
  • newMap: A map of IDs to the new versions of the sObject records. This map is only available in before update, after insert, after update, and after undelete triggers.
  • old : Returns a list of the old versions of the sObject records. This sObject list is only available in update and delete triggers.
  • oldMap: A map of IDs to the old versions of the sObject records. This map is only available in update and delete triggers.
  • size: The total number of records in a trigger invocation, both old and new.

 

Trigger Context Variables Considerations

  • trigger.new and trigger.old cannot be used in Apex DML operations.
  • You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved, so a runtime exception is thrown.
  • trigger.old is always read-only.
  • You cannot delete trigger.new.

 

For interview questions related to trigger, refer to below link:

Salesforce Interview Questions on Triggers

For more details about context variable, please refer to below official link:

Trigger Context Variables in Salesforce

 

Permanent link to this article: http://www.sfdcpoint.com/salesforce/trigger-context-variables-in-salesforce/

Salesforce Interview Questions on Triggers

Salesforce Interview Questions on Triggers

In this post I am going to share Salesforce Interview Questions on Triggers

What is a Trigger?

Apex triggers enable you to perform custom actions before or after events to records in Salesforce, such as insertions, updates, or deletions. Just like database systems support triggers, Apex provides trigger support for managing records.

Use triggers to perform tasks that can’t be done by using the point-and-click tools in the Salesforce user interface. For example, if validating a field value or updating a field on a record, use validation rules and workflow rules instead.

What is Trigger Syntax?

trigger TriggerName on ObjectName (trigger_events) {
   code_block
}

What are the various event on which a trigger can fire?

A trigger is a set of statement which can be executed on the following events. In above trigger events one or more of below events can be used with comma separated.

  • before insert
  • before update
  • before delete
  • after insert
  • after update
  • after delete
  • after undelete

What are different type of Triggers?

There are two types of triggers:

  • Before triggers are used to perform a task before a record is inserted or updated or deleted. These are used to update or validate record values before they are saved to the database.
  • After triggers are used if we want to use the information set by Salesforce system and to make changes in the other records. are used to access field values that are set by the system (such as a record’s Id or LastModifiedDate field), and to affect changes in other records. The records that fire the after trigger are read-only.

What are the considerations while implementing the Triggers?

Consider the following before implementing the triggers.

  • Upsert trigger fires on 4 different events :- before(insert, update), after (insert, update)
  • Merge trigger are fired on both events on delete
  • Field history is updated after the trigger has successfully finished processing data.
  • Any callout should be asynchronous so that trigger does not have to wait for the response.
  • A trigger cannot have a static keyword in its code.
  • If a trigger completes successfully the changes are committed to the database and if it fails the transaction is rolled back.

Read the Apex Developer Guide for more detailed considerations.

What are context variables in triggers?

All triggers define implicit variables that allow developers to access run-time context. These variables are contained in the System.Trigger class.

Following are the context variable available in triggers. Please note variable availability in trigger varies according to the type of trigger events.

  • isExecuting: Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call.
  • isInsert: Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API.
  • isUpdate: Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.
  • isDelete: Returns true if this trigger was fired due to a delete operation, from the Salesforce user interface, Apex, or the API.
  • isBefore: Returns true if this trigger was fired before any record was saved.
  • isAfter: Returns true if this trigger was fired after all records were saved.
  • isUndelete: Returns true if this trigger was fired after a record is recovered from the Recycle Bin (that is, after an undelete operation from the Salesforce user interface, Apex, or the API.)
  • new: Returns a list of the new versions of the sObject records. This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
  • newMap: A map of IDs to the new versions of the sObject records. This map is only available in before update, after insert, after update, and after undelete triggers.
  • old : Returns a list of the old versions of the sObject records. This sObject list is only available in update and delete triggers.
  • oldMap: A map of IDs to the old versions of the sObject records. This map is only available in update and delete triggers.
  • size: The total number of records in a trigger invocation, both old and new.

Refer to Trigger context variables in salesforce link for more details.

How is Trigger.New Different from Trigger.newMap?

Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.NewMap returns the map of ID’s with the newly entered records. NewMap is only available in after insert, before and after the update and after undelete.

How is Trigger.new different from Trigger.old?

Trigger.New variable returns the list of sObject which has invoked the trigger and Trigger.old returns a list of the older versions of the records which have invoked the trigger. Trigger.Old is only available in update and delete events

Can a trigger call a batch class?

Yes, we can call a batch class in the trigger as we do in the normal apex code.

Can a trigger make a call to Apex callout method?

we can call a callout method in Apex Trigger but the only condition is that it has to be an asynchronous callout because the trigger flow cannot wait on the response received by the callout method.

Define Recursive Trigger and how to avoid it?

There is a possibility that the result of the trigger can end up calling the same trigger again and can run in a loop, this is known as a recursive trigger. To avoid this scenario we should create a static variable and check the value of this variable before we execute anything in the trigger. For more details refer to below link:

Avoid recursive trigger in salesforce

What do you mean by the bulkifying trigger?

A trigger should be able to handle single record and thousands of record. There are two important point for it:

  • Write triggers that operate on collections of sObjects.
  • Write triggers that perform efficient SOQL and DML operations.

If we will not follow above point we may hit governor limit when records are created/updated/deleted in mass using data loader or other tool.

Bulk Apex Trigger trailhead

Is there any limit on number of triggers define on an object?

We can define as many triggers on an object as we want but it is recommended to have one trigger per object because the order of execution of different trigger is not guaranteed and any trigger can fire first.

Can you explain the order of execution in Triggers?

Following is the order of execution of events which Salesforce perform before a DML Event.

  1. The record is loaded from the database or is initialized in case of upset statement.
  2. New record’s field values are overwriting the old values, now depending on the origin of the request this flow varies: if the request is from a UI page then the following validations are performed by Salesforce:
    1. Any layout specific rules are checked
    2. All the required values are checked at layout and field level
    3. All the field formats are validated along with the maximum length of field values

If the request originates other than UI then Salesforce only checks for Validation of foreign keys.

  1. Now all the before triggers are executed at the database.
  2. Most of the validations are performed again to verify that all the required fields are holding some values and are not null, at this step user defined validations are also executed and the only validation which is not repeated in this step are the rules specific to the layout.
  3. After the success of the previous step, the record is reviewed for duplicate records, by running the duplicate rule. If a duplicate is found the flow is stopped and no further actions performed.
  4. In this step, record is saved to the database but it not committed yet.
  5. Now all the after Triggers are executed.
  6. In this step, assignment rules are executed.
  7. Now if there is any auto-response rule is present then they are executed.
  8. Next in the queues are the workflow, they are executed after the auto response.
  9. If the workflow was updating a field, then the fields updated in this step and the flow after this step varies if this was the case.
  10. If a field was updated then the before and after update triggers are fired once more and standard validation are also executed again. Custom validation escalation rule and duplicate rules are not required to run again.
  11. Once the execution has reached this stage, then process is fired if there are any declared on the object.
  12. Now the escalation rules are executed.
  13. Entitlement rules are executed if any.
  14. If there are any roll-up summary field, then they are calculated at this step and the parent object go through the save process.
  15. Now the sharing rules are executed.
  16. If we reach this stage, then that means no error has occurred and the data is ready to be committed to the database and is committed now.
  17. Now if there is any post-commit logic like email, then that is executed.

 

For more details about trigger please refer below links

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

Trailhead get started with Triggers

Other posts related to interview questions

Salesforce lightning interview questions

I will keep adding more questions to Salesforce Interview Questions on Triggers.

Permanent link to this article: http://www.sfdcpoint.com/salesforce/salesforce-interview-questions-on-triggers/

Loading spinner in lightning component

Loading spinner in lightning component

What is Lightning Spinner?

Loading spinner in lightning component

Spinners are CSS loading indicators that should be shown when retrieving data or performing slow computations. lightning:spinner displays an animated spinner image to indicate that a request is loading. This component can be used when retrieving data or performing an operation that takes time to complete.

aura:waiting and aura:donewaiting can be used for controlling the loading spinner.

What is aura:waiting and aura:doneWaiting?

aura:waiting : This event is automatically fired when a server side apex action is added using $A.enqueueAction(). This event is always fired before aura:doneWaiting. It is handled by a client-side (javaScript)controller. One component can have only one tag to handle this event.

aura:doneWaiting : This event is automatically fired when all server response(apex)  complete. aura:doneWaiting indicate that the lightning component is done waiting for server response. This event is always fired after aura:waiting. It is handled by a client-side (javaScript)controller. One component can have only one tag to handle this event.

Lightning Loading Spinner Example :

There are two ways of showing lightning spinner. First is using lightning design system.

Loading Spinner using lightning design system

Loading Spinner Apex class
public class AccountController{
    @AuraEnabled
    public static List <Account> fetchAccounts() {
        //Qyery 10 accounts
        List<Account> accList = [SELECT Id, Name, BillingState, 
                                    Website, Phone from Account LIMIT 10];
        //return list of accounts
        return accList;
    }
}
Loading Spinner Lightning Component
<aura:component controller="AccountController">
    <!--aura handler with waiting and donewaiting events--> 
    <aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
    <aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
    
  	<!--component attributs -->
    <aura:attribute name="spinner" type="boolean" default="FALSE"/>
    <aura:attribute name="accListToDisplay" type="Account[]" />
    
    <!--loading spinner start-->
    <aura:if isTrue="{!v.spinner}">
        <div aura:id="spinnerId" class="slds-spinner_container">
            <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
                <span class="slds-assistive-text">Loading...</span>
                <div class="slds-spinner__dot-a"></div>
                <div class="slds-spinner__dot-b"></div>
            </div>
        </div>
    </aura:if>
    <!-- Loading spinner end-->    
    
    <!-- Account section start-->
    <ui:button label="Fetch Accounts" class="slds-button slds-button--neutral" press="{!c.getAccounts}"></ui:button>
    <h3 class="slds-section-title--divider">Account List</h3>
    
    <!-- iterate all Account by aura:iteration and display in table--> 
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">
                <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
                <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
                <th scope="col"><div class="slds-truncate" title="BillingState">BillingState</div></th>
                <th scope="col"><div class="slds-truncate" title="Website">Website</div></th>
                <th scope="col"><div class="slds-truncate" title="Phone">Phone</div></th>
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.accListToDisplay}" var="acc">
                <tr>
                    <th scope="row"><div class="slds-truncate" title="{!acc.Id}">{!acc.Id}</div></th>
                    <td><div class="slds-truncate" title="{!acc.Name}">{!acc.Name}</div></td>
                    <td><div class="slds-truncate" title="{!acc.BillingState}">{!acc.BillingState}</div></td>
                    <td><div class="slds-truncate" title="{!acc.Website}">{!acc.Website}</div></td>
                    <td><div class="slds-truncate" title="{!acc.Phone}">{!acc.Phone}</div></td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>

We can define different styles for spinners. Refer this link for more details

https://www.lightningdesignsystem.com/components/spinners/

 

Loading Spinner Lightning component javascript controller
({
    getAccounts : function(component, event, helper) {
        //call getAccountsHelper method
        helper.getAccountsHelper(component, event, helper);
    },
    
    // function automatic called by aura:waiting event  
    showSpinner: function(component, event, helper) {
        // make Spinner attribute true for displaying loading spinner 
        component.set("v.spinner", true); 
    },
    
    // function automatic called by aura:doneWaiting event 
    hideSpinner : function(component,event,helper){
        // make Spinner attribute to false for hiding loading spinner    
        component.set("v.spinner", false);
    }
})
Loading Spinner Lightning component helper
({
	getAccountsHelper : function(component, event, helper) {
        //call apex class method
        var action = component.get('c.fetchAccounts');
        action.setCallback(this, function(response) {
            //store state of response
            var state = response.getState();
            if (state === "SUCCESS") {
                //set response value in accListToDisplay attribute on component.
                component.set('v.accListToDisplay', response.getReturnValue());
            }
        });
        $A.enqueueAction(action);
    },
})
Loading Spinner Lightning component style
.THIS.slds-spinner_container {  
  z-index: 10000;
  position: fixed;   
}
Loading Spinner Lightning Application
<aura:application extends="force:slds">
    <c:LoadingSpinnerExample/>
</aura:application>

Output will look like this when Fetch account button is clicked:

Loading spinner in lightning component

Loading spinner in lightning component

lightning:spinner example

Loading Spinner using lightning:spinner tag

A lightning:spinner displays an animated spinner image to indicate that a feature is loading. This component can be used when retrieving data or anytime an operation doesn’t immediately complete.

Apex class code will be same. There will be slight difference in Lightning component and client side controller.

lightning spinner Lightning Component
<aura:component controller="AccountController">
    <!--aura handler with waiting and donewaiting events--> 
    <aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
    <aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
    
  	<!--component attributs -->
    <aura:attribute name="accListToDisplay" type="Account[]" />
    
    <!--loading spinner start-->
    <div class="exampleHolder">
        <lightning:spinner aura:id="mySpinner" class="slds-hide"/>
    </div>
    <!-- Loading spinner end-->    
    
    <!-- Account section start-->
    <ui:button label="Fetch Accounts" class="slds-button slds-button--neutral" press="{!c.getAccounts}"></ui:button>
    <h3 class="slds-section-title--divider">Account List</h3>
    
    <!-- iterate all Account by aura:iteration and display in table--> 
    <table class="slds-table slds-table_bordered slds-table_striped slds-table_cell-buffer slds-table_fixed-layout">
        <thead>
            <tr class="slds-text-heading_label">
                <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
                <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
                <th scope="col"><div class="slds-truncate" title="BillingState">BillingState</div></th>
                <th scope="col"><div class="slds-truncate" title="Website">Website</div></th>
                <th scope="col"><div class="slds-truncate" title="Phone">Phone</div></th>
            </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.accListToDisplay}" var="acc">
                <tr>
                    <th scope="row"><div class="slds-truncate" title="{!acc.Id}">{!acc.Id}</div></th>
                    <td><div class="slds-truncate" title="{!acc.Name}">{!acc.Name}</div></td>
                    <td><div class="slds-truncate" title="{!acc.BillingState}">{!acc.BillingState}</div></td>
                    <td><div class="slds-truncate" title="{!acc.Website}">{!acc.Website}</div></td>
                    <td><div class="slds-truncate" title="{!acc.Phone}">{!acc.Phone}</div></td>
                </tr>
            </aura:iteration>
        </tbody>
    </table>
</aura:component>
lightning spinner javascript controller
({
    getAccounts : function(component, event, helper) {
        //call getAccountsHelper method
        helper.getAccountsHelper(component, event, helper);
    },
    
    // function automatic called by aura:waiting event  
    showSpinner: function(component, event, helper) {
        // remove slds-hide class from mySpinner
        var spinner = component.find("mySpinner");
        $A.util.removeClass(spinner, "slds-hide");
    },
    
    // function automatic called by aura:doneWaiting event 
    hideSpinner : function(component,event,helper){
        // add slds-hide class from mySpinner    
        var spinner = component.find("mySpinner");
        $A.util.addClass(spinner, "slds-hide");
    }
})

We can have different type of spinner. Refer to below official link for more details lightning spinner

Other similar posts related to lightning components

Salesforce Lightning Interview Questions

 

Permanent link to this article: http://www.sfdcpoint.com/salesforce/loading-spinner-in-lightning-component/

Organization Wide Defaults(OWD) in salesforce

Organization Wide Defaults(OWD) in salesforce

What is OWD In Salesforce?

Organization Wide Defaults(OWD) in salesforce is the baseline level of access that the most restricted user should have. Organizational Wide Defaults are used to restrict access. You grant access through other means like(sharing rules, Role Hierarchy, Sales Teams and Account teams, manual sharing, Apex Sharing ). In simple words Organization Wide Defaults(OWD) specify the default level of access users have to each other’s records.

Object permissions determine the baseline level of access for all the records in an object. Org-wide defaults modify those permissions for records a users doesn’t own. Org-wide sharing settings can be set separately for each type of object.

Important to note that Org-wide defaults can never grant users more access than they have through their object permission.

There are mainly four levels of access :

  • Public Read/Write/Transfer (only available of Leads and Cases)
  • Public Read/Write : All users can view, edit, and report on all records(Given that they have object level permission).
  • Public Read/Only : All users can view and report on records, but only the owner, and users above that role in the hierarchy, can edit them.
  • Private : Only the record owner, and users above that role in the hierarchy, can view, edit, and report on those records.

 

How to determine OWD for your org:

To determine the org-wide defaults you need for your app, ask yourself these questions about each object:

  1. Who is the most restricted user of this object?
  2. Is there ever going to be an instance of this object that this user shouldn’t be allowed to see?
  3. Is there ever going to be an instance of this object that this user shouldn’t be allowed to edit?
Organization Wide Defaults(OWD) in salesforce

Deciding owd in Salesforce

For more detail check this trailhead module.

Setting owd in Salesforce

  1. In Setup, use the Quick Find box to find Sharing Settings.
  2. Click Edit in the Organization-Wide Defaults area.
  3. For each object, select the default access you want to give everyone.
  4. To disable automatic access using your hierarchies, deselect Grant Access Using Hierarchies for any custom object that does not have a default access of Controlled by Parent.

 

owd in salesforce

owd in salesforce

 

For Interview questions related to Salesforce security, please refer below post.

Salesforce security interview questions

Permanent link to this article: http://www.sfdcpoint.com/salesforce/organization-wide-defaults-owd-in-salesforce/

Salesforce Lightning Interview Questions

Salesforce Lightning Interview Questions

In this post I am going to share Salesforce Lightning Interview Questions

Here is list of all Salesforce Lightning Interview Questions:

  • What is Salesforce Lightning?
  • What are the tools included in lightning ?
  • What is Aura? Why do I see the aura: namespace in the code?
  • Is Lightning an MVC framework?
  • What is difference between Visualforce Components and Lightning Components?
  • Where we can display lightning component?
  • What are the different Lightning component bundles?
  • What is Lightning Experience?
  • What is Lightning Design System?
  • What happens to my existing Visualforce Pages?
  • What are the type of events into Salesforce Lightning component?
  • What is the basic difference between Application Event and Component Event?
  • Component events vs Application events. Which one I should use?
  • What is aura definition bundle?
  • What is the use of implements in lightning component?
  • Which interface we are supposed to implement so that a lightning component can be used as a Tab?
  • Which interface we are supposed to implement so that a lightning component can be used as quick action?
  • Which interface we are supposed to implement so that a lightning component can be used in Community builder?
  • What is use of @AuraEnabled annotation
  • Can we Include One Lightning component to another ?
  • How can we use Lightning Components with the Salesforce1 Mobile App ?
  • How can we use a lightning component in a VisualForce Page?
  • Can we integrate Lightning components with another framework like Angular?
  • Can we include external JavaScript/CSS libraries like jQuery, bootstrap in components?
  • What is use of aura:method tag in salesforce lightning?
  • How to ensure FLS while working with Lightning Component?
  • How can we display loading spinner in lightning component?
  • How can we conditionally display content in lightning component?
  • What is the use of force:hasRecordId interface?
  • How to get current record id in lightning component?
  • What is a FlexiPage in lightning?
  • How can we deploy lightning components?
  • What Is Lightning Data Service?
  • What is Locker Service in Salesforce Lightning?
  • What are value providers in Salesforce Lightning ?
  • What are List of Global value providers in lightning?
  • How to create popup in lightning component?

 

Here is list of all Salesforce lightning interview questions and answers:

What is Salesforce Lightning?

Lightning is the collection of tools and technologies behind a significant upgrade to the Salesforce platform. Lightning includes:

  • Experience: A set of modern user interfaces optimized for speed. This includes the Lightning Experience, Salesforce1 Mobile app and template-based communities.
  • Lightning Component Framework: A JavaScript framework and set of standard components that allow you to build reusable components to customize the Lightning Experience, Salesforce1 Mobile app and template-based communities and build your own standalone apps.
  • Visual Building Tools: Drag-and-drop technologies for fast and easy app building & customizations. Use the Lightning App Builder to customize the Lightning Experience and Salesforce1 Mobile app. Use the Community Builder to customize template-based communities.
  • Lightning Exchange: A section of the AppExchange where you can find 70+ partner components to jumpstart your development.
  • Lightning Design System: Style guides and modern enterprise UX best practices to build pixel perfect apps that match the look and feel of the Lightning Experience and Salesforce1 Mobile app.
Salesforce Lightning Interview Questions

Salesforce Lightning Interview Questions

What are the tools included in lightning ?

  • Lightning Component Framework – Components and extensions that allow you to build reusable components, customize the Salesforce1 Mobile App, and build standalone apps.
  • Lightning App Builder – A new UI tool that lets you build apps lightning fast, using components provided by Salesforce and platform developers.
  • Lightning Connect – An integration tool that makes it easier for your Force.com app to consume data from any external source that conforms to the OData spec.
  • Lightning Process Builder – A UI tool for visualizing and creating automated business processes.
  • Lightning Schema Builder – A UI tool for viewing and creating objects, fields, and relationships.

What is Aura? Why do I see the aura: namespace in the code?

Aura is the open source technology that powers Lightning Components. The aura: namespace contains all of the basic building blocks for defining components and applications.

Is Lightning an MVC framework?

No, it’s a component-based framework.

What is difference between Visualforce Components and Lightning Components?

Visualforce components are page-centric and most of the work is done on the server. Lightning is designed from the component up, rather than having the concept of a page as its fundamental unit. Lightning Components are client-side centric, which makes them more dynamic and mobile-friendly.

Where we can display lightning component?

There are a number of possibilities for display lightning component..

  •  Lightning Experience: We can display component in the Lightning Experience using the App Builder. We can edit the home page, edit a record detail page or create/edit a new app page to include it.
  •  Salesforce1 Mobile app: We can display component in the Salesforce1 Mobile app by creating a custom Lightning tab that references it and adding that tab in mobile navigation.
  • Standalone Lightning app: By create a standalone Lightning app (e.g. myapp.app) and include component in this app. Access Lightning app by URL.
  • Add Apps to the Lightning Experience App Launcher: Your Lightning Components apps and custom tabs are available from the App Launcher.
  • Add Apps to Lightning Experience and Salesforce App Navigation:  You can add Lightning components tabs to an app and they display as items in the app’s navigation bar.
  • Lightning App Builder and Community Builder : We can display component in template-based (e.g. Napili) community using the Community Builder. Build custom user interfaces using your own Lightning components, or those you install from AppExchange, for desktop and mobile devices.
  • Add Lightning Components to Lightning Pages: A Lightning Page is a custom layout that lets you design pages for use in the Salesforce mobile app or in Lightning Experience. You can use a Lightning Page to create an app home page and add your favorite Lightning component, such as the Expenses app we’ll be creating in this module, to it.
  • Add Lightning Components to Lightning Experience Record Pages: You can customize Lightning Experience record pages by adding a Lightning Component.
  • Launch a Lightning Component as a Quick Action: Create actions using a Lightning component, and then add the action to an object’s page layout to make it instantly accessible from a record page.
  • Create Stand-Alone Apps: A standalone app comprises components that use your Salesforce data and can be used independently from the standard Salesforce environment.
  • Run Lightning Components Apps Inside Visualforce Pages: Add Lightning components to your Visualforce pages to combine features you’ve built using both solutions. Implement new functionality using Lightning components and then use it with existing Visualforce pages.
  • Run Lightning Components Apps on Other Platforms with Lightning Out: Lightning Out is a feature that extends Lightning apps. It acts as a bridge to surface Lightning components in any remote web container. This means you can use your Lightning components inside of an external site (for example, Sharepoint or SAP), or even elsewhere on the platform such as on Heroku.
  • Customize Flow Screens: Create a flow to guide your users through a business process. By default, you can add simple fields like inputs or radio buttons to a flow screen. But with a custom Lightning component, you can fully customize the look-and-feel and functionality of your screen.

What are the different Lightning component bundles?

  • Component :UI for lightning component
  • Controller: Contains client-side controller methods to handle events in the component.
  • Helper: JavaScript functions that can be called from any JavaScript code in a component’s bundle
  • Style: Contains styles for the component.
  • Document: A description, sample code, and one or multiple references to example components
  • Design: File required for components used in Lightning App Builder, Lightning pages, or Community Builder.
  • SVG: Custom icon resource for components used in the Lightning App Builder or Community Builder.
  • Renderer: Client-side renderer to override default rendering for a component.

Click Here for official Salesforce documentation.

What is Lightning Experience?

Lightning Experience is the name for the all new Salesforce desktop app, with new features, built with a modern user interface and optimized for speed.

What is Lightning Design System?

Style guides and modern enterprise UX best practices to build pixel perfect apps that match the look and feel of the Lightning Experience and Salesforce1 Mobile app. Click Here for official link.

What happens to my existing Visualforce Pages?

They’ll continue to be supported in the current UI and Lightning Experience. See the Trailhead module on this topic.

What are the type of events into Salesforce Lightning component?

  • Application Event – Scope of this event is throughout the lightning App and any component which has registered for this event would get a notification.
  • Component Event– Scope of this event is within itself or the parent component of this event, all the components declared within the parent component would get notified of this event.
  • System Event- these are the events fired by Salesforce’s system during the lifecycle of the lightning app.

 

What is the basic difference between Application Event and Component Event?

Component events are used to do communication between child and parent. They use bubbling and capture same as used in DOM events. A change in a child component can be communicated to the parent component via component event.

Application events are used to communicate any change in the component to a broader audience. Any component who has registered for this event will get a notified.

Component events vs Application events. Which one I should use?

Component events can only be handled by components above them in the containment hierarchy, therefore, their usage is localized to the components that need to know about them.

Application events are best used for something that should be handled at the application level, such as navigating to a specific record. Application events allow communication between components that are in separate parts of the application and have no direct containment relationship.

What is aura definition bundle?

A bundle contains an Aura definition and its related resources. The definition can be a component, application, event, interface, or a tokens collection.

An AuraDefinitionBundle component is a folder that contains definition files. Unlike most other metadata components, an AuraDefinitionBundle component isn’t a single file, it’s a collection of files. Each file represents a resource in a bundle, such as markup, applications, code files (including controllers and helpers), events, documentation, and interfaces.

A bundle doesn’t have a suffix. Definition files can have one of these suffixes:

SuffixComponent Type
.appApplication
.cmpComponent
.designDesign
.evtEvent
.intfInterface
.jsController, Helper, or Renderer
.svgSVG Image
.cssStyle
.auradocDocumentation
.tokensTokens collection

What is the use of implements in lightning component?

Implements is use to refer platform interfaces which enables a component to be used in different contexts or to grant access to extra context data, a component can implement more than one interfaces.

Here is list of all interfaces that can be implemented in lightning component

Which interface we are supposed to implement so that a lightning component can be used as a Tab?

We need to implement the following “force:appHostable” so that we can use the component as a Tab.

Which interface we are supposed to implement so that a lightning component can be used as quick action?

We need to implement the following “force: lightningQuickAction” so that we can use the component as a Quick Action.

Which interface we are supposed to implement so that a lightning component can be used in Community builder?

We need to implement the following “forceCommunity:availableForAllPageTypes” so that we can use the component in community builder.

What is use of @AuraEnabled annotation

How to call apex class from lightning component

The AuraEnabled annotation enables Lightning components to access Apex methods and properties.

The AuraEnabled annotation is overloaded, and is used for two separate and distinct purposes.

  • Use @AuraEnabled on Apex class static methods to make them accessible as remote controller actions in your Lightning components.
  • Use @AuraEnabled on Apex instance methods and properties to make them serializable when an instance of the class is returned as data from a server-side action.

For more details, please refer to lightning:datatable example

Can we Include One Lightning component to another ?

Yes we can include one Lightning component inside another Lightning component

How can we use Lightning Components with the Salesforce1 Mobile App ?

We can create a custom Lightning tab that points to our component and include that tab in our Salesforce1 Mobile navigation.

How can we use a lightning component in a VisualForce Page?

A Lightning component can be embed in any webpage using a very powerful and flexible feature, Lighting out. When used with Visualforce some complexity becomes simpler.
Lightning component can be added to Visualforce page in three steps:

  1. We have to first Add the Lightning Components for Visualforce JavaScript library to your targetted Visualforce page using the tag.
  2. Next we have to create and refer a Lightning app which is used to the component dependencies.
  3. Lastly we need to write a JavaScript function which will finally create the the component on the page using $Lightning.createComponent()

For more details, please refer Use Lightning Components in Visualforce Pages

Can we integrate Lightning components with another framework like Angular?

Yes, we can integrate lightning with any 3rd party framework.

Can we include external JavaScript/CSS libraries like jQuery, bootstrap in components?

Yes, we can use multiple libraries in our lightning component like JQuery, Bootstrap, custom CSS and custom Javascript libraries using static resource.

What is use of aura:method tag in salesforce lightning?

We can use <aura:method> to define a method as part of a component’s API. This enables you to directly call a method in a component’s client-side controller instead of firing and handling a component event. Using <aura:method> simplifies the code needed for a parent component to call a method on a child component that it contains.

How to ensure FLS while working with Lightning Component?

FLS and CRUD are not automatically enforced in the lightning component whenever any object is referenced in the Apex Controller and the component will display the fields and records for which the users do not have access. Therefore we should manually enforce the FLS and CRUD in the Apex Controller. Also when we use Lightning Data service  it takes care of FLS and CRUD for us.

How can we display loading spinner in lightning component?

Spinners are CSS loading indicators that should be shown when retrieving data or performing slow computations. lightning:spinner displays an animated spinner image to indicate that a request is loading. This component can be used when retrieving data or performing an operation that takes time to complete.

aura:waiting and aura:donewaiting can be used for controlling the loading spinner.

For more details please refer to below post lightning spinner

How can we conditionally display content in lightning component?

We can use aura:if to conditionally display content in lightning component. For more details refer to below post aura:if in lightning component

What is the use of force:hasRecordId interface?

or

How to get current record id in lightning component?

Add the force:hasRecordId interface to a Lightning component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on. This interface has no effect except when used within Lightning Experience, the Salesforce mobile app, and template-based communities.

For more details refer below link force:hasRecordId

What is a FlexiPage in lightning?

FlexiPage represents the metadata associated with a Lightning page. A Lightning page represents a customizable screen made up of regions containing Lightning components.
A Lightning page can contain upto 25 components. Flexi page are stored as xml file and can be deployed using metadata api or any deployment tool.

Lightning pages are referred as FlexiPages in API and referred as Lightning pages elsewhere in SFDC documentation.

How can we deploy lightning components?

Lightning components can be deployed similar to any other component using changeset, ant migration tool, eclipse or any other migration tool.

What Is Lightning Data Service?

Use Lightning Data Service to load, create, edit, or delete a record in your component without requiring Apex code. Lightning Data Service handles sharing rules and field-level security for you. In addition to not needing Apex, Lightning Data Service improves performance and user interface consistency. Main advantage of using lightning data service is that we can perform basic operations without Apex code.

For more details refer to below link Lightning Data Service

What is Locker Service in Salesforce Lightning?

Locker Service is a powerful security architecture for Lightning components. Locker Service enhances security by isolating Lightning components that belong to one namespace from components in a different namespace. Locker Service also promotes best practices that improve the supportability of your code by only allowing access to supported APIs and eliminating access to non-published framework internals.

For more details please refer below link: Locker Services

What are value providers in Salesforce Lightning ?

Value Providers in lightning Component encapsulate related values together and used to access data. In Salesforce lightning, we have two value providers for a component they are v (View) and c (Controller).

  • v is component attribute set which helps to access component attribute values in markup
  • c is component controller helps us to link with event handlers and action for the component

What are List of Global value providers in lightning?

  • $globalID
  • $Browser
  • $Label
  • $Locale
  • $Resource

 

How to create popup in lightning component?

Modals/Popup Box are used to display content in a layer above the app. This paradigm is used in cases such as the creation or editing of a record, as well as various types of messaging and wizards.

For more details, refer to below link Modal/Popup Lightning Component Salesforce

 

If you have any other useful question answer related to Salesforce Lightning Interview Questions, please add in comment section.

Please refer to below links for more detail about lightning:

Lightning FAQ

Lightning Design System

Lightning Experience Rollout Specialist

Lightning Component Framework Specialist

Lightning Experience Specialist

Lightning Components Developer Guide

I will keep adding more questions to Salesforce Lightning Interview Questions.

For other interview questions please refer to Salesforce interview questions

Permanent link to this article: http://www.sfdcpoint.com/salesforce/salesforce-lightning-interview-questions/

Salesforce security interview questions

Salesforce security interview questions

Salesforce security interview questions or data and security salesforce interview questions

There are different levels of security that is implemented in Salesforce. This post is related to data and security.

What are different Levels of data access in Salesforce?

Organization level security

For your whole org, you can maintain a list of authorized users, set password policies, and limit logins to certain hours and locations.

Object level security

Access to object-level data is the simplest thing to control. By setting permissions on a particular type of object, you can prevent a group of users from creating, viewing, editing, or deleting any records of that object. For example, you can use object permissions to ensure that interviewers can view positions and job applications but not edit or delete them.

Field level security

You can restrict access to certain fields, even if a user has access to the object. For example, you can make the salary field in a position object invisible to interviewers but visible to hiring managers and recruiters.

Record level security

You can allow particular users to view an object, but then restrict the individual object records they’re allowed to see. For example, an interviewer can see and edit her own reviews, but not the reviews of other interviewers. You can manage record-level access in these four ways.

  • Organization-wide defaults
  • Role hierarchies
  • Sharing rules
  • Manual sharing

 

Salesforce security interview questions

Salesforce security interview questions

What is Organization-wide defaults?

Organization Wide Defaults(OWD) in salesforce is the baseline level of access that the most restricted user should have. Organizational Wide Defaults are used to restrict access. You grant access through other means like(sharing rules, Role Hierarchy, Sales Teams and Account teams, manual sharing, Apex Sharing ). In simple words Organization Wide Defaults(OWD) specify the default level of access users have to each other’s records.

For more details please level to below post Organization Wide Defaults(OWD) in salesforce

What is role hierarchy?

It gives access for users higher in the hierarchy to all records owned by users below them in the hierarchy. Role hierarchies don’t have to match your organization chart exactly. Instead, each role in the hierarchy should represent a level of data access that a user or group of users needs.

What are Sharing Rules?

Sharing Rules are automatic exceptions to organization-wide defaults for particular groups of users, so they can get to records they don’t own or can’t normally see. Sharing rules, like role hierarchies, are only used to give additional users access to records. They can’t be stricter than your organization-wide default settings.

What is Manual sharing?

It allows owners of particular records to share them with other users. Although manual sharing isn’t automated like org-wide sharing settings, role hierarchies, or sharing rules, it can be useful in some situations, such as when a recruiter going on vacation needs to temporarily assign ownership of a job application to someone else.

Some more questions for Salesforce security interview questions post.

What is Profile

Each user has a single profile that controls which data and features that user has access to. A profile is a collection of settings and permissions. Profile settings determine which data the user can see, and permissions determine what the user can do with that data.
  • The settings in a user’s profile determine whether she can see a particular app, tab, field, or record type.
  • The permissions in a user’s profile determine whether she can create or edit records of a given type, run reports, and customize the app.

Profiles usually match up with a user’s job function (for example, system administrator, recruiter, or hiring manager), but you can have profiles for anything that makes sense for your Salesforce org. A profile can be assigned to many users, but a user can have only one profile at a time.

What are standard profiles?

  • Read Only
  • Standard User
  • Marketing User
  • Contract Manager
  • System Administrator

 

What is Permission Set?

A permission set is a collection of settings and permissions that give users access to various tools and functions. The settings and permissions in permission sets are also found in profiles, but permission sets extend users’ functional access without changing their profiles.

Permission sets make it easy to grant access to the various apps and custom objects in your org, and to take away access when it’s no longer needed.

Users can have only one profile, but they can have multiple permission sets.

 

What is “View all” and “Modify all” permission?

View all and Modify all permissions are usually given to system administrator. When you grant “View All” or “Modify All” for an object on a profile or permission set, you grant any associated users access to all records of that object regardless of the sharing and security settings.

In essence, the “View All” and “Modify All” permissions ignore the sharing model, role hierarchy, and sharing rules that the “Create,” “Read,” “Edit,” and “Delete” permissions respect. Furthermore, “Modify All” also gives a user the ability to mass transfer, mass update, and mass delete records of that specific object, and approve such records even if the user is not a designated approver.

These tasks are typically reserved for administrators, but because “View All” and “Modify All” let us selectively override the system, responsibilities that are usually reserved for the administrator can be delegated to other users in a highly controlled fashion.

 

Is it possible to restrict permission for users using permission set?

No, Permission Set always extends the permission. It does not restrict permission to users.

If a user does not have access to a specific record type, will they be able to see the records that have that record type?

Yes, Record type controls only visibility of record on UI but not its access to users. If user does not have access to record type then user will not be able to create records for that record type using UI. But user will we able to see records if they have appropriate permission to do so.

For more details related to salesforce security please refer to this trailhead module Data Security

If you have any question related to Salesforce security interview questions, please add your comments

I will keep adding more questions to Salesforce security interview questions.

 

Permanent link to this article: http://www.sfdcpoint.com/salesforce/salesforce-security-interview-questions/