April 21, 2019

Salesforce Interview Questions with Answers Part 55

1. Only Last PushTopic Notification Sent for the Same Record

In API version 36.0 and earlier, when multiple PushTopic notifications are generated for the same record within about one millisecond and in the same transaction, only the last notification is sent.
The other notifications are suppressed because notifications are tracked at the millisecond level. When multiple notifications happen within a transaction at the same time—less than one millisecond—only the last notification can be delivered.

PushTopic notification from Bulk API
Updates performed by the Bulk API won’t generate notifications since such updates could flood a channel.

2. Formula fields in PushTopic Query

Formula fields in WHERE clauses are not supported.

Formula fields are supported in SELECT clauses though.

3. Time dependent process actions in Process Builder

In Process Builder time based actions are available when "only when a record is created" is selected. For "when a record is created or edited", if you select "Do you want to execute the actions only when specified changes are made to the record?" in the criteria then time based actions will appear.

4. Subscribe reports email notification content

On the Schedule Report page, specify a running user who has access to the folder where the report is stored.

The access level of the running user determines what other users, including portal users, see when they receive the scheduled report run results.

5. How to avoid locking contention in Salesforce?

Always sort the file by the lookup / master-detail field that represents the parent record. For example, if loading Contacts, sort by AccountId field to minimize locking contention on the parent records.

6. Transfer Record profile permission

To transfer multiple accounts, campaigns, contacts, contracts, and custom objects:

Transfer Record AND Edit on the object type

To transfer multiple leads:

Transfer Leads OR Transfer Record AND Edit on leads

To transfer multiple cases:

Transfer Cases OR Transfer Record AND Edit on cases

OWD or Sharing Rules or Role Hierarchy won't work since Transfer Record override it.

User with "Transfer Record" permission allowed to transfer ALL records, as long as the user has Edit permission to the object. Read again here "edit on object" NOT "edit on record", this means, the user will be able to transfer record owner even user do not have Edit access to that record.

7. Purpose of comments in coding

The real purpose of comments is to explain “WHY” you did something, not “WHAT” thecode is doing. If you don’t explain this, other programmers may be confused and when they go to change your code they might remove important parts of it.

8. System  and User mode in Salesforce

Trigger runs in System mode. If triggers calls an apex class with sharing keyword, then record level access will be considered.

Validation Rule runs in System mode.

Auto Response Rule runs in System mode.

Assignment Rule runs in System mode.

Workflow Rule runs in System mode.

Escalation Rule runs in System mode.

Formula, Rollup Summary runs in System mode.

Process Builder runs in System mode.

Custom Button runs in System mode.

Visual Workflow or flow runs in User mode.
If flow is called from Process Builder, then runs in System mode.
If flow is called from Workflow, then runs in System mode.
If flow is called from Apex, then runs in (depends on with or without sharing of apex class).
If flow is called from Custom Button, then runs in System mode.
If flow is embed in Visualforce, then runs in VFP context.
If flow is called from REST API, then runs in System mode.

Approval Process runs in System mode.

Publisher Action runs in System mode.

InvocableMethod
If this is called from flow, then runs in User mode.
If this is called from Process Builder (does it depends on with or without sharing is specified on that Class), then runs in System mode.
if this is called from REST API, then runs in (depends on with or without sharing of the class).

Test method with System.runAs() runs in User mode.
Test method without System.runAs() runs in System mode.

Visualforce Page (StandardController) runs in User mode.
Visualforce Page (StandardController with extension) runs in System mode.
Visualforce Page (Custom Controller) - Based on the sharing keyword usage in the apex class.
Visualforce Component runs in depends on Visualforce page where it is used.

Macros runs in System mode.

Annonymous Apex runs in User mode.

Chatter in Apex runs in User mode.

Email Service runs in User mode.

All types of Jobs runs in System mode.

Apex Webservices (SOAP API and REST API) runs in System mode.

9. Send Email Actions in Salesforce

Send Email actions are supported in Lightning Experience only.

10. Test file naming convention for LWC

In your component bundle, create a folder called __tests__ and a JavaScript class called componentName.test.js. It’s a best practice to name the file after the component, followed by .test.js.

11. Canvas App

Canvas enables you to easily integrate a third-party application in Salesforce. Canvas is a set of tools and JavaScript APIs that you can use to expose an application as a canvas app. This means you can take your new or existing applications and make them available to your users as part of their Salesforce experience.

Canvas App Previewer

Canvas App Previewer is a development tool that lets you see what your canvas apps will look like before you publish them.

The third-party app that you want to expose as a canvas app can be written in any language. The only requirement is that the app has a secure URL (HTTPS).

apex:canvasApp is the tag to use in Visualforce page.

12. When Child Events get Created in Salesforce? 

While creating a new event/editing an existing event, we have the ability to invite people. So, for the invitees(users/contacts/leads), Salesforce internally creates separate events for each invitee with the flag isChild=TRUE.

13. Flow and Process Builder running mode

Flow in User Mode, PB in System Mode. Trigger the Flow from PB and it runs in System Mode. Mind. Blown.

14. What is ALM?

Application lifecycle management (ALM) is the product lifecycle management (governance, development, and maintenance) of computer programs. It encompasses requirements management, software architecture, computer programming, software testing, software maintenance, change management, continuous integration, project management, and release management.

15. What is the wire service?

Lightning web components(lwc) use reactive wire service to read Salesforce data.
It is Built on Lightning Data service.
Components use @wire in their JavaScript class to read data from one of the wire adapters in the lightning/ui*Api namespace.
Reactive wire service supports reactive variables, which are prefixed with $. If a reactive variable changes, the wire service provisions(requests) new data.

wire service syntax
import { adapterId } from 'adapterModule';
@wire(adapterId, adapterConfig)
propertyOrFunction;

16. How to Reset My Security Token when IP restriction is applied in the profile in Salesforce?

Use below URL
https://[SalesforceDomainHere].my.salesforce.com/_ui/system/security/ResetApiTokenEdit?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DPersonalInfo&setupid=ResetApiToken

or

https://login.salesforce.com/_ui/system/security/ResetApiTokenEdit?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DPersonalInfo&setupid=ResetApiToken

17. Will IsUnreadByOwner change fires trigger?

The IsUnreadByOwner field changing doesn't fire an update trigger.

Idea - https://success.salesforce.com/ideaView?id=08730000000BqU2

18. Sign in Error: 'Login Rate Exceeded'

When attempting log in you should limit the amount of requests to ensure proper processing.
The limit is 3600 calls per user per hour.
If this limit is exceed a “Login Rate Exceeded” error is generated in your application and Salesforce login history.
This limit ensures that our platform runs safely and efficiently.

19. Sender Policy Framework (SPF) and Salesforce SPF records

Sender Policy Framework is a simple email-validation system designed to detect email spoofing by providing a process to verify which providers are permitted to send emails on your behalf. It also aims to reduce the number of spam and fraud by making it harder for anyone to hide their identity.

If you’re sending an email from a Salesforce application and your domain is abc.com, you can create an SPF record that authorizes Salesforce.com mail servers as allowed mail servers for abc.com domain. When the recipient receives your email, it checks the SPF record of abc.com to determine if it’s a valid email. The message will have a high chance of delivery if it can be validated using SPF.

20. Advanced PDF to Render Visualforce Pages as PDF Files

Advanced PDF renders Visualforce pages as PDF files with broader support for modern HTML standards, such as CSS3, JavaScript, and HTML5. This change applies to both Lightning Experience and Salesforce Classic.

To use Advanced PDF, set renderAs="advanced_pdf" in the <apex:page> tag of a Visualforce page with API version 40.0 or later.

Limitations:

If you use inline CSS styles, set the API version to 28.0 or later. Also set <apex:page applyBodyTag="false">, and add static, valid <head> and <body> tags to your page, as in the previous example.
The maximum response size when creating a PDF file must be less than 15 MB before being rendered as a PDF file. This limit is the standard limit for all Visualforce requests.
The maximum file size for a generated PDF file is 60 MB.
The maximum total size of all images included in a generated PDF is 30 MB.
PDF rendering doesn’t support images encoded in the data: URI scheme format.
The following components don’t support double-byte fonts when rendered as PDF.
<apex:pageBlock>
<apex:sectionHeader>
These components aren’t recommended for use in pages rendered as PDF.
If an <apex:dataTable> or <apex:pageBlockTable> has no <apex:column> components that are rendered, rendering the page as PDF fails. To work around this issue, set the table component’s rendered attribute to false if none of its child <apex:column> components are rendered.

21. What does <article> HTML Tag do?

The <article> element identifies a self-contained piece of content which could theoretically be distributed to other websites and platforms as a stand-alone unit. The <article> element is a good choice to contain entire blog posts, news articles, and similar content.
Display: block
Usage: semantic or structural

22. Types of Flows

1. Auto Launched Flow
2. Screen Flow

Lightning Flow—the product that encompasses building, managing, and running flows and processes.
Flow Builder—a point-and-click tool for building flows.
Flow—an application that automates a business process by collecting data and doing something in your Salesforce org or an external system

23. Modify All

Users can read, edit, delete, transfer, and approve all records associated with this object, regardless of sharing settings.

24. Set Apex Class Access from Profiles

These settings apply only to Apex class methods. For example, apply the settings to Web service methods or any method used in a custom Visualforce controller or controller extension applied to a Visualforce page. Triggers always fire on trigger events (such as insert or update), regardless of profile settings.

25. What is meant by the Read / Unread status of leads?

A user will have a list of unread leads that they own and can be viewed under the list view of My Unread Leads.
When you transfer ownership of a lead, the lead will appear in the new owner's 'My Unread Leads' view, until they click on the lead.

Note: For leads owned by a Queue, the status will remain 'Unread', even if a member of the Queue reviews it.

26. What is the difference between (profile) login hours and (company information) business hours? Does business hours different from login hours or do business hours override the login hours?

Business hours don’t override profile hours. Login hours are for specifying when users can log in. Business hours are for specifying when the support team is available and to help manage other processes like escalations and milestones.

27. What information we get during PushTopic delete event?

Salesforce Id.
If the SOQL is SELECT Id, Name, Industry FROM Account, we will not get Name and Industry during delete event.

28. Delete Field History and Field Audit Trail Data

Use Apex or SOAP to delete field history and field history archive data.
To delete field history and audit trail data, the user permissions Delete From Field History and Delete From Field History Archive must be enabled through a permission set or a user profile. The org preferences to enable these permissions, Delete From Field History and Delete From Field History Archive, are located in Setup | User Interface.

Delete field history data, such as AccountHistory, and field history archive data by passing in a list of ID values as strings using the Apex or SOAP delete() method. The Apex delete() method also works with a list of sObjects with the Id field populated.

The sObject acts like a template. All rows that match the sObject’s fields and values are deleted. You can only specify fields that are part of the big object’s index. You must specify all fields in the index. You can’t include a partially specified index or non-indexed field, and wildcards are not supported.

Sample for deleting AccountHistory:

List<AccountHistory> ah = new List<sObject>();    
ah.addAll( [ SELECT Id FROM AccountHistory WHERE AccountId = '001d000000Ky3xIAB' AND CreatedDate = YESTERDAY ] );    

Database.delete(ah);    

Samples for deleting from FieldHistoryArchive:

List<FieldHistoryArchive> fha = new List<sObject>();  
fha.addAll([SELECT FieldHistoryType, ParentId, CreatedDate, HistoryId FROM FieldHistoryArchive WHERE FieldHistoryType = 'Account' AND  ParentId = '001d000000Ky3xIAB' AND CreatedDate = '2017-11-28T19:13:36.000z' AND  HistoryId = '017D000000ESURXIA5']);  

Database.delete(fha); 

29. lightning-record-view-form component

A lightning-record-view-form component is a wrapper component that accepts a record ID and is used to display one or more fields and labels associated with that record using lightning-output-field.

lightning-record-view-form requires a record ID to display the fields on the record. It doesn't require additional Apex controllers or Lightning Data Service to display record data. This component also takes care of field-level security and sharing for you, so users see only the data they have access to.

Supported Objects
This component doesn't support all Salesforce standard objects. For example, the Event and Task objects are not supported.

30. Example for Ternary operator:

Integer ListPrice = 50;
Integer SalesPrice = 100;
Integer TotalAmount = ListPrice > 50 ? ListPrice : SalesPrice;
System.debug(‘::TotalAmount::’+ TotalAmount);

No comments:

Post a Comment