Concepts or coding lessons of Salesforce that you can implement easily

How to use Salesforce Sites Visualforce page in an iFrame on external website

I have implemented Visualforce pages in Force.com Sites. but I have to use that page in 5 different client sites. then what is the possible ways to achieve this?

Workarounds are:

Create 5 different VF pages with specific styling related to each site brand and then share each VF page with a specific team.

Problem: any change in requirements or fields would need to me change every VF page.

Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

Best Solution:

Display site's page on external in an iFrame by the following method


  • Goto Setup -> Site settings.
  • Set the "Clickjack Protection Level" to "Allow framing by any page (no protection)".- same like below image.
  • Press "Save" button.

Difference between component.find() component.get() in Salesforce Lightning

component.find()

Find the button component by calling cmp.find("button1") in your client-side controller, where cmp is a reference to the component containing the button.

Syntax: component.find("auraid");

find() returns different types depending on the result.

  1. If the local ID is unique, find() returns the component.
  2. If there are multiple components with the same local ID, find() returns an array of the components.
  3. If there is no matching local ID, find() returns undefined.
component.get()

Returns the value referenced using property syntax. 

Syntax: component.get(String key) 

For example, cmp.get("v.attr") returns the value of the attr aura:attribute.

Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

Full Example:



Lightning Component:



<aura:component >
    <aura:attribute name="LighningPageProperty" type="String" default="Demo"/>
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
    <ui:inputText aura:id="inputComponent" class="slds-input" value="{!v.LighningPageProperty}" />
    <ui:inputText aura:id="auraid" class="slds-input"/>    
</aura:component>

Lightning Controller: 

({
    doInit : function(component, event, helper) {
        component.find("auraid").set("v.value", "Search Example");
        component.set("v.LighningPageProperty", "Find Example");
        var val = component.get("v.LighningPageProperty"); 
    },    
})



Beware Critical Update for Salesforce Lightning Users, Read Immediately !!

If you are using Visual Force pages used in Lightning Console, then this is very Important news for you...

Currently $User.UITheme or $User.UITheme Displayed returns Theme4d for Visual Force pages used in Lightning Console. 

Once the Critical Updates is activated, Theme4u will be returned for the case.

Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

Customers need to make changes to their Visual Force code prior to activating the Critical Updates if they use the following type of code to determine whether the Visual Force page is used in Lightning:

function inLightningExperience() {
  return 'Theme4d' === '{!$User.UIThemeDisplayed}';
}

Instead, use the following code to determine whether it is in Lightning or not:

function inLightningExperience() {
  return ['Theme4d', 'Theme4u'].indexOf('{!$User.UIThemeDisplayed}') > -1; 

How to show difference with and without Lightning Locker Service for Lightning Components?

This is the summary of Lightning Locker Service in Salesforce. 

If you are not aware of Lightning Locker Service then I strongly recommend, Learn Lightning Locker Service here.

What Locker Service does is prohibit certain types of behaviors, such as trying to peek into the DOM of a component outside your own namespace.

For example, Locker Service disallows the following code example:

<lightning:button aura:id="button1" label="My Button" />

var element = component.find("button1").getElement();



Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

You can’t use component.find("button1").getElement() to access the DOM element created by lightning:button

Locker Service doesn’t allow a Lightning component to access the DOM for lightning:button because the button is in the lightning namespace and Lightning Component is in the namespace.


Check out Disabling Locker Service for a Particular Component In Salesforce Expert Interview


Latest Salesforce Interview Questions and Answers:

Disabling Locker Service for a Particular Component In Salesforce Expert Interview

If you are not aware of Lightning Locker Service in Salesforce, then I strongly recommend,
Learn Lightning Locker Service here.👈


You can disable LockerService for a component by setting version 39.0 or lower for the component. If a component is set to at least API version 40.0, which is the version for Summer '17, LockerService is enabled.

LockerService is disabled for any component created before Summer '17 because these components have an API version less than 40.0.

Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

Component versioning enables you to associate a component with an API version. When you create a component, the default version is the latest API version. In Developer Console, click Bundle Version Settings in the right panel to set the component version.

Check out How to show the difference with and without Lightning LockerService using lightning components?

Latest Salesforce Interview Questions and Answers:


Lightning Locker Service In Salesforce: This Is What Professionals Do

The Lightning LockerService architectural layer enhances security by isolating individual Lightning components in their own namespace and enforcing coding best practices. 

LockerService prevents security issues and unsupported practices when you develop your own Lightning components or use third-party libraries in your Lightning components.

LockerService enforces security in:
  • Lightning Experience
  • Salesforce
  • Template-based Communities
  • Standalone apps that you create (for example, myApp.app)
  • Lightning Out, including Lightning Components for Visualforce

Learn Learning Salesforce Lightning Application Development to accelerate your Career with Salesforce!!! 

Locker Service doesn’t affect the following except for usage of Lightning components in Visualforce in these contexts:
  • Salesforce Classic
  • Visualforce-based communities
  • Any apps for Salesforce Classic, such as Salesforce Console in Salesforce Classic
LockerService enforces several security features in your Lightning code, including:

1. JavaScript ES5 Strict Mode Enforcement is implicitly enabled
You don't need to specify "use strict" in your code. Enforcement includes a declaration of variables with the var keyword and other JavaScript coding best practices. Any libraries that your components use must also work in strict mode.

2. A component can only traverse the DOM and access elements created by a component in the same namespace
This behavior prevents the anti-pattern of reaching into DOM elements owned by components in another namespace.

Become EXPERT in APEX with Salesforce Lightning.

3. LockerService applies restrictions to global references
You can access intrinsic objects, such as Array. LockerService provides secure versions of non-intrinsic objects, such as a window. The secure object versions automatically and seamlessly control access to the object and its properties.

4. Enforcement of access to published, supported JavaScript API framework methods only
These methods are published in the reference doc app at https://yourDomain.lightning.force.com/auradocs/reference.app. Previously, private and unsupported methods were accessible, which exposed your code to the risk of breaking when these methods were changed or removed.

Check out below to more about Lightning LockerService


3 Easy Ways To Make Learn System mode & User mode Components In Salesforce Faster

System mode: process running is NOT DEPEND on the current user permissions to the object access, field level security, sharing rule. In which the level permissions of the current user are ignored.

User mode: process running is DEPEND on the current user permission to the object access, field level security, sharing rule. In which the level permissions of the current user are enforced.

System Mode Components


  • Apex Trigger 
  • Apex Webservices (SOAP API and REST API)
  • All types of Apex Jobs 
  • Apex Test method without System.runAs() 
  • Visualforce Page (StandardController with extension) 
  • Validation Rule 
  • All Types of calculation behind the formula 
  • Rollup Summary 
  • Workflow Rule
  • Process Builder
  • If InvocableMethod is called from Process Builder
  • If Visual flow is called from REST API 
  • If Visual flow is called from Process Builder
  • If Visual flow is called from Custom Button 
  • If Visual flow is called from Workflow
  • Approval Process 
  • Auto Response Rule 
  • Assignment Rule
  • Escalation Rule
  • Publisher Action 
  • Custom Button 
  • Macros 
User Mode Components


  • Test method with System.runAs()
  • Visualforce Page (StandardController)
  • Visual Workflow or flow
  • If InvocableMethod is called from Visual flow
  • Annonymous Apex
  • Chatter in Apex
  • Email Service
Learn Force.com Enterprise Architecture to accelerate your Career with Salesforce!!! 

Decided on Run time based on Component Context


  • If InvocableMethod is called from REST API - It depends on with sharing OR without sharing of apex class
  • If Visual flow is called from Apex - It depends on with sharing OR without sharing of apex class which executes flow
  • If Visual flow is embedded in Visualforce - Depends on Visualforce page context
  • Visualforce Page (CustomController) - It depends on with sharing OR without sharing of apex class
  • Visualforce Component - It depends on a Visualforce page where it is used

Latest Salesforce Interview Questions and Answers:

More Salesforce Blogs:

How To Fetch All Private Reports Of Particular Users In Salesforce?
Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best 
Export VisualForce Data into Excel Sheet in 3 Easiest Steps

Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.

How To Fetch All Private Reports Of Particular Users In Salesforce ?

SOQL Query:

SELECT Id, Name, Owner.Name FROM ReportUSING SCOPE allPrivate WHERE Owner.Name LIKE '%Mike%'

Want to Fetch All Private Reports Of All Users easily then check post:
How To Fetch All Private Reports Of All Users In Salesforce?


Latest Salesforce Interview Questions and Answers:



More Salesforce Blogs:

How To Fetch All Private Reports Of All Users In Salesforce?
Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best 
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal

How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time



Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.

How To Fetch All Private Reports Of All Users In Salesforce ?

Sometimes we have to Fetch All Private Reports Of All Users In Salesforce.


We can see each user private reports after logged in as a feature.

But its time-consuming.

Here is Simple and Easy Solution to access All Private Reports Of All Users In Salesforce:


SOQL Query:


SELECT Id, Name, Owner.Name FROM Report USING SCOPE allPrivate

Note: This functionality is available only for use on the Dashboards and Reports objects. It is not currently supported for use with queries against the DashboardComponent object.

Features required for this functionality:


If the following features are not enabled, you'll receive an error titled INVALID_QUERY_SCOPE. 
  1. Enable Reports & Dashboard Folder Sharing for the organization (Entire Organization)
  2. Expose the "Manage All Private Reports and Dashboards" User Perm (Entire Organization) NOTE: If this feature is not available, please contact Salesforce Support to have it enabled.
  3. Manage All Private Reports and Dashboards (For the profile of the user performing the search:)

Want to Fetch All Private Reports Of Particular Users easily then check post:

How To Fetch All Private Reports Of Particular Users In Salesforce?


Latest Salesforce Interview Questions and Answers:



More Salesforce Blogs:

Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best 
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal

How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time



Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.

How To Get All Field Names For All Objects Using Apex In Salesforce?

Apex Code:


You can fetch all object names without Schema.SObject, Check it out my other post: 
How to Fetch all object names in Salesforce without Schema.SObjectType ?

Latest Salesforce Interview Questions and Answers:


More Salesforce Blogs:

Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best 
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal

How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time


Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.

How to Fetch all object names in Salesforce without Schema.SObjectType ?

Can we fetch all object names in Salesforce without Schema.SObjectType ?

Answer:

Yes, we can fetch that using below SOQL query:

SELECT QualifiedApiName FROM EntityDefinition ORDER BY QualifiedApiName

Result:
























You can fetch all object`s field names, Check it out my other post: 
How To Get All Field Names In All Objects Using Apex In Salesforce?

Latest Salesforce Interview Questions and Answers:



More Salesforce Blogs:

Check out Salesforce Daily Limit Only in 5 Simplest Steps
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best 
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal

How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time


Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.