About Me

My photo
PLANO, Texas, United States

Sunday, July 25, 2021

Identity and Access Management

In the real world of salesforce, we might need to connect other applications seamlessly without compromising security, and Identity & Access Management deal with this complication.

In the below picture, salesforce is communicating with different cloud applications like a workday, mule, and other cloud-based applications. Along with this, it connected with Social clouds like Facebook, Linkedin, or Twitter, and premise systems that might be sitting behind the firewall, and mobile applications. 

In the above flow, There are two questions have been raised apart from Integration:

  1. How do you determine the identity (Authentication) of the user to be logged in. For example, if someone logged in to salesforce and wanted to open Facebook, you facebook understand the identity of that user.

  2. How do you determine the access (Authorization) of the user?


Identity & Access Management provides the answer to these two questions. Identity & Access Management ensures:

-the right people to get

-the right access

-the right resource 

-at the right time.

Authentication Vs Authorization 

Authentication

Authorization

Process of identifying a user based on a set of verifiable credentials such as username & password.

Determines if a user has permission to access resources on the server.

Process or action of proving or showing something to be true, genuine, or valid.

Verify the access of authenticated user and can grant or deny the access

Authentication means who a person is. These days, authentication is often used as shorthand for authorization and authentication.

Authorization means what a person can do.

Authentication can be done on the server itself or it can be sent to a 3rd party to authenticate.

Authorization cannot be done without authentication

Identify Management deals for authentication. 

Access Management deals with authorization.

You control who can access your orgs and who can use apps running on the Salesforce Platform, on-premises, in other clouds, and on mobile devices.

You control what can be accessed in your orgs after authentication.


Benefits of Identity 

You control who can access your orgs and who can use apps running on the Salesforce Platform, on-premises, in other clouds, and on mobile devices with Identity which can help you in different ways:

  • Convenience - Employees can log in to a workstation and connect to a Salesforce org without logging in again. In fact, they can have a single login that works for all their web and mobile apps. You can give them one-click access to third-party productivity tools and services, like Gmail or Microsoft Office 365. Users don’t have to remember lots of usernames and passwords.

  • Control - Managers and supervisors can have more control over their employees. If you want fine-grained control over who uses what, you can require that a manager or supervisor approve employee requests to access an app or service. And when you need to revoke access to an app, you can do that, too.

  • Security - The magic of Salesforce Identity is that more convenience plus greater control adds up to enhanced security. One identity source for user credentials across corporate networks and the web makes it easy for you and other Salesforce admins to monitor and manage usage. Reduce redundant accounts, and you reduce your vulnerability to malicious activity. And with multi-factor authentication, you can be twice as confident that your users are who they claim to be.

Features provided of Salesforce Identity

Identity helps to log in to the system in an easier way without compromising security. There are multiple features that support Salesforce Identity:

  • Single sign-on

  • Connected apps

  • Social sign-on

  • Multi-factor authentication

  • My Domain

  • Centralized user account management

  • User provisioning

  • Identity Connect

  • App Launcher

Identity Standards & Protocols-

There are industry standards and protocols for identity and access management which helps users’ identities secure when they don’t have to sign in to external websites or apps. A standard is just a set of widely agreed-upon practices that industry members follow. A standard can include a protocol that specifies how systems exchange information.

Here are the three protocols that Salesforce and other identity vendors follow to implement identity solutions.

  1. SAML

  2. OAuth 2.0

  3. OpenID Connect

SAML Protocol-

When you want users to move seamlessly between Salesforce orgs and applications without logging in repeatedly, you set up single sign-on (SSO). SAML is an XML-based protocol, which means that the packages of information being exchanged are written in XML.

Here are a couple of examples of SAML in action.

  • When you’re logged in to Salesforce and then click the App Launcher to get directly to your Gmail inbox, that’s SAML in action.

  • When users who are already logged in to another app can access their Salesforce org without logging in again, that’s also SAML in action.

How does SAML work?

  • A user tries to access a service. The service provider sends out a request to the identity provider basically asking, “Hey, is it okay if this user accesses my service?” The identity provider makes sure that users are who they say they are by checking its database and then returning a response—an assertion—saying, “Yes, this user is authorized, and here’s some information about the user.”

  • The assertion is the information being sent. An assertion can carry detailed information about a user. It can also contain attributes about the user, like first and last names, contact information, maybe even the job title.

  • SAML happens in the background. Your users don’t see any of it. They just click an icon or link and open another app without having to provide additional information or log in again. Sometimes their destination already knows something about them (those user attributes) when they get there.


OAuth 2.0 Protocol

OAuth 2.0 is an open protocol used to allow secure data sharing between applications. The user works in one app but sees the data from another. For example, you’re logged in to your Salesforce mobile app and see your data from your Salesforce org.

Behind the scenes, the apps perform a kind of handshake and then ask the user to authorize this data sharing. When developers want to integrate their app with Salesforce, they use OAuth APIs. Here are a couple of examples.

  • A mobile app that pulls contacts from a Salesforce org uses OAuth.

  • A Salesforce org gets contacts from another service also uses OAuth.

  • Workbench uses oAuth 2.0 protocol for connecting with salesforce.


The following is an example of an app asking the user for permission to access information using OAuth 2.0.


OpenID Connect Protocol

  • The OpenID Connect protocol adds an authentication layer on top of OAuth 2.0 to enable secure exchange of user information. Like SAML, OpenID Connect sends identity information from one service to another. Unlike SAML, OpenID Connect is built for today’s world of social networks. Have you ever installed a new app and come across a prompt like "Log in with your Google account"? That app is using the OpenID Connect protocol. When you sign in with Google, you’re not creating an account and another password. Only Google holds that information.

  • The app developer used the OpenID Connect protocol to enable social sign-on.For instance, when Google verifies a user’s identity on behalf of another service, it’s authenticating the user. In this way, Google is an identity provider.

  • Salesforce builds in support for several major social identity providers, including Google, Facebook, and LinkedIn. If a provider isn’t supported out of the box, you can still use it if it implements the OpenID Connect protocol—Amazon and PayPal, for example.


The advantage of the OpenID Connect protocol for users is that they can reduce the number of separate accounts, usernames, and passwords. On the flip side, developers can authenticate their users across websites and apps without having to own and manage password files. This process makes it that much harder for hackers to compromise user accounts.

Service Providers and Identity Providers

In the process of authenticating users, SAML exchanges identity information between the holder of the information called an identity provider (IdP), and the desired service, called a service provider. For Example- In the case where a user logs in to Salesforce and then accesses Gmail, Salesforce is the identity provider, and Google is the service provider. Salesforce can be both a service provider and an identity provider.


Salesforce as a Service Provider

Authenticated users can flow from an external identity provider into Salesforce. In this case, Salesforce is a service provider—users want to get access to this service, and their identity provider allows them to do so. This Salesforce configuration is common because often your company is already using an identity provider. The identity provider could be one of several on the market, like Microsoft’s Active Directory Federation Services (ADFS), Ping Identity’s PingFederate, open-source Shibboleth, or ForgeRock’s OpenAM.


Users log in from an identity provider and are then redirected to Salesforce (the service provider). In another module, you’ll set up SSO with Salesforce as a service provider and a third-party application as the external identity provider.


Salesforce as an Identity Provider

Authenticated users can also flow from Salesforce to other clouds and apps. In this case, Salesforce acts as an identity provider and provides SSO for users to connect to different service providers.


Saturday, May 15, 2021

Large Data Volume (LDV)

Data is one of the key elements. As the system gets older, data size gets increased. These large data volumes (LDV) can lead to performance issues, including slower queries, slower search and list views, and slower sandbox refreshing. When we deal with large data volume, we may have below three actions that need to be taken care of:
  1. Conduct data query & Search- This includes a selective query, Skinny table, etc.
  2. Load the data- Use Lean Loading
  3. Perform data deletion & extraction - Hard delete, PK chunking
Best practices, can address the issue in the early stages while searching, loading, deleting, or extracting the data. Let's talk about possible data issues and their resolution along with different tools used for data issues.

What is Data Skew?

Data skew primarily refers to a non-uniform distribution in a dataset. Whenever data is distributed non uniformly, it leads to performance issues. We need to architect our design to avoid data skew.

Problems due to Data Skew

  1. Record Locking -You’re updating a large number of contacts under the same account in multiple threads. For each update, the system locks both the contact being changed and its parent account to maintain integrity in the database. Even though each lock is held for a very short time, because all the updates are trying to lock the same account, there’s a high risk an update will fail because a previous one is still holding the lock on the account.
  2. Sharing Issues- There’s a similar dynamic when it comes to sharing. Depending on how you have sharing configured, when you do something that seems simple, like changing the owner of an account, you may need to examine every one of the account’s child records and adjust their sharing, as well. That may include recalculating the role hierarchy and sharing rules. And if we’re talking about hundreds of thousands of child records, that can eat up tons of time.

Types of Data Skew

There are different three types of data skews.
  1. Ownership Skew
  2. Account Data Skew
  3. Lookup Skew 

Ownership Skew

  • When a large number of records with the same object type are owned by a single user, this imbalance causes ownership skew. 
  • When the skewed owner exists in the role hierarchy, operations like deletes or owner updates must remove sharing from the old owner and all parent users within the role hierarchy, and from all users given access by sharing rules. That’s why ownership changes tend to be one of the most costly transactional changes in the system.
  • Example-An integration user creating lots of records without assigning them to a new owner or a customer can assign all of his or her unassigned leads to a dummy user. 
  • In some cases, an ownership skew simply can’t be avoided. In these cases, it’s best to ensure the skewed owner doesn’t have a role or keep the user in the top role hierarchy. That way, you take the user and their records away from the role hierarchy and its associated sharing rules.

Account Data Skew

  • Certain Salesforce objects, like accounts and opportunities, have special data relationships that maintain parent and child record access under private sharing models. Too many child records associated with the same parent object in one of these relationships cause account data to skew.

Lookup Skew

  • Lookup skew happens when a very large number of records are associated with a single record in the lookup object. Because you can place lookup fields on any object in Salesforce, lookup skew can create problems for any object within your organization.

Index

An index is used to improve the speed of data retrieval. If you often search a table or sort its records by a particular field, you can speed up these operations by creating an index for the field. The following fields are indexed by default:
  • Primary keys (ID, Name, and Owner fields).
  • Foreign keys (lookup or master-detail relationship fields).
  • Audit dates (such as SystemModStamp). 
  • Custom fields marked as External ID or Unique.
You can use Query Plan to see if your query is Index or not.

Force.com Query Optimize

There are some symptoms that use complaint slowness about unresponsive reports, dashboard taking a long time to load, list view taking forever display, slowness on Lightning pages and you frequently getting Apex/ SOQL errors & timeouts. If you have seen these in your org, then you may have a SOQL problem. The Force.com query optimizer tool optimizes the SOQL used to fetch data by inspecting SOQL, Reports, and List Views.



  • The Force.com query optimizer is an engine that sits between your SOQL, reports, and list views, and the database itself. Because of salesforce.com’s multitenancy, the optimizer gathers its own statistics instead of relying on the underlying database statistics.  
  • Pre-computed Statistics contains the following information
    • Row Count
    • User Visibility
    • Custom index
    • Owner row count

Working with Very Large SOQL Queries

Use SOQL FOR

Your SOQL query sometimes returns so many sObjects that the limit on heap size is exceeded and an error occurs. To resolve, use a SOQL query for loop instead, since it can process multiple batches of records by using internal calls to query and queryMore.

Use selective query

Whenever you work in production, soql query plays a crucial role, an indexed query does not guarantee a selective query. A query is selective
  • When one of the query filters is on an indexed field
  • The query filter reduces the resulting number of rows below a system-defined threshold.
The performance of the SOQL query improves when two or more filters used in the WHERE clause meet the mentioned conditions. Force.com query Optimizer decides whether a query is selected or not.
 























A query is selective when one of the query filters is on an indexed field and the query filter reduces the resulting number of rows below a system-defined threshold. The performance of the SOQL query improves when two or more filters used in the WHERE clause meet the mentioned conditions.

The selectivity threshold is 10% of the records for the first million records and less than 5% of the records after the first million records, up to a maximum of 333,000 records. In some circumstances, for example with a query filter that is an indexed standard field, the threshold may be higher. Also, the selectivity threshold is subject to change.

Common Causes of Non-Selective SOQL Queries

  • Performing Large Data Loads
    • Large data loads and deletions can affect query performance. The Force.com query optimizer uses the total number of records (including soft deleted) as part of the calculation for its selectivity threshold.
    • If you are deleting, huge data, it is recommended to use hard delete
    • EXAMPLE- Suppose if your query is fetching cards (Custom Object) with Status as Available and you have loaded around 300K active cards which makes a total count of 500K. Force.com query optimizer will not consider this as a selective query. You may need to change the card status as On Hold and write some batch which can make the card Available, by checking Threshold. 
  • Using Leading % Wildcards- LIKE condition with a leading % wildcard does not use an index.  SELECT id FROM Account WHERE Name LIKE ‘%Acme%’  Note: Within a report/list view, the CONTAINS clause translates into ‘%string%’.
  • Using NOT and != When your filter uses != or NOT—which includes using NOT EQUALS/CONTAINS for reports, even if the field is indexed—the Force.com query optimizer can’t use the index to drive the query. For better performance, filter using = or IN, and the reciprocal values.
  • Using Complex Joins -Complex AND/OR conditions and sub-queries require the Force.com query optimizer to produce a query that is optimized for the join, but might not perform as well as multiple issued queries would. This is especially true with the OR condition. For Force.com to use an index for an OR condition, all of the fields in the condition must be indexed and meet the selectivity threshold. If the fields in the OR condition are in multiple objects, and one or more of those fields does not meet a selectivity threshold, the query can be expensive.
  • Avoiding nulls -We should avoid null values in the query filter, if you don’t have an option to avoid, create the formula field to convert Null value to some defined value and use it in your soql.

Best Practice to avoid non-selective query

To ensure that your queries are selective, avoid some common pitfalls. Also, if you feel your query is fine and you may need to enable a custom index, you can call salesforce and they can assist you to enable a custom index. Note-A custom index can't be created on these types of fields: multi-select picklists, currency fields in a multicurrency organization, long text fields, some formula fields, and binary fields (fields of type blob, file, or encrypted text.) 

  • Understand your schema and have proper indexes created.
  • Apply as many filters as possible to reduce the result set.
  • Minimize the amount of records in the Recycle Bin.

Remember that NOT operations and LIKE conditions with a leading % wildcard do not use indexes, and complex joins might perform better as separate queries. 

Bulk Queries

Use bulk queries to fetch large data in an efficient way.

  • A bulk query can retrieve up to 15 GB of data, divided into fifteen 1 GB files.
  • Bulk API query supports both query and queryAll operations. The queryAll operation returns records that have been deleted because of a merge or delete. 

How Bulk Queries Are Processed?

  • When a bulk query is processed, Salesforce attempts to execute the query. If the query doesn’t execute within the standard two-minute timeout limit, the job fails and a QUERY_TIMEOUT error is returned. If this happens, rewrite a simpler query and resubmit the batch.
  • If the query succeeds, Salesforce attempts to retrieve the results. If the results exceed the 1 GB file size limit or take longer than 10 minutes to retrieve, the completed results are cached and another attempt is made. After 15 attempts, the job fails and the error message Retried more than fifteen times is returned. If this happens, consider using the PK Chunking header to split the query results into smaller chunks. If the attempts succeed, the results are returned and stored for seven days.

Skinny Tables

Let's say you followed coding best practices and worked with Salesforce Customer Support to place custom indexes wherever appropriate, but you’re still encountering performance problems. Users are complaining about their reports and dashboards timing out, and the SOQL called from your Visualforce page is performing slower and slower. If you desperately need to further improve performance, there’s a special, powerful solution: skinny tables.

  • A skinny table is a custom table in the Force.com platform that contains a subset of fields from a standard or custom base Salesforce object. Force.com can have multiple skinny tables if needed and maintains them and keeps them completely transparent to you.
  • Skinny tables can be a convenient means of remedying performance issues. But they might not accommodate all use cases, or improve performance more than reading from the base Salesforce object with efficient indexes. They come with side effects you should understand because they might restrict or burden your business processes. Here are a few things to consider before implementing skinny tables:
    • Skinny tables are skinny. To ensure optimal performance, they contain only the minimum set of fields required to fulfill specific business use cases. If you later decide to add a field to your report or SOQL query, you must contact Salesforce Customer Support to recreate the table.
    • For Full sandboxes: Skinny tables are copied to your Full sandbox orgs. For other types of sandboxes: Skinny tables aren’t copied to your sandbox organizations. To have production skinny tables activated for sandbox types other than Full sandboxes, contact Salesforce Customer Support.
    • Skinny tables are custom tables in the underlying Force.com database. They don’t have the dynamic metadata flexibility you find in the base object. If you alter a field type (for example, change a number field to a text field) the skinny table becomes invalid, and you must contact Salesforce Customer Support to create a new skinny table.

Perform Data Deletes and Extracts

Deletion & Extraction is one of the key processes in LDV. We might be using delete and extract for defining the archive process and we might be using a 3rd party tool to take care. When you have very huge data, we must follow best practices to have a smooth business. In this topic, we will understand more about key aspects of data delete and extract.

Bulk API

Bulk API is very useful when it comes to LDV. You can get more detail for Bulk API from my Integration API blog

Soft vs. Hard Deletion

  • Whenever you delete the data in salesforce, by default, it goes to the recycle bin for 15 days. This deletion is called soft delete. When data is soft deleted, it still affects database performance because it’s still living in the org, and deleted records have to be excluded from any queries.
  • Bulk API supports a hard delete (physical delete) option, which allows records to bypass the Recycle Bin and immediately become available for deletion. Using Bulk API’s hard delete function is a recommended strategy for deleting large data volumes to free up space sooner and keep extraneous material from affecting performance. Note that the hard delete option is disabled by default and must be enabled by an administrator.

Chunking Data

  • When extracting data with Bulk API, queries are split into 100,000 record chunks by default—you can use the chunkSize header field to configure smaller chunks or larger ones up to 250,000. Larger chunk sizes use up fewer Bulk API batches but may not perform as well. You might need to experiment a bit to determine the optimal chunk size.
  • At extremely high volumes—hundreds of millions of records—defining these chunks by filtering on field values may not be practical. The number of rows that are returned may be higher than the selectivity threshold of Salesforce’s query optimizer. The result could be a full table scan and slow performance, or even failure. Then you need to employ a different strategy.

Using PK Chunking

  • So if attribute filtering doesn’t help you break the data up into small enough chunks, what can you do? Use PK Chunking to handle extra-large data set extracts. PK stands for Primary Key—the object’s record ID—which is always indexed. PK chunking splits bulk queries on very large tables into chunks based on the record IDs of the queried records.
  • You can use PK Chunking with most standard objects. It’s supported for Account, Campaign, CampaignMember, Case, Contact, Lead, LoginHistory, Opportunity, Task, and User, as well as all custom objects. To enable the feature, specify the header Sforce-Enable-PKChunking on the job request for your Bulk API query.
  • Salesforce recommends that you enable PK chunking when querying tables with more than 10 million records or when a bulk query constantly times out.

Truncation

  • If you want to delete records in a sandbox org’s custom objects immediately, you can try truncating those custom objects. Truncating custom objects is a fast way to permanently remove all the records from a custom object while keeping the object and its metadata intact for future use.
  • Truncating is useful, for example, if you have created a custom object and filled it with test records. When you’re done with the test data, you can truncate the object to purge the test records, but keep the object and put it into production. This is much faster than batch-deleting records and possibly recreating the object.

Lean Loading

Whether we’re talking LDV migration or ongoing large data sync operations, A smart strategy for accomplishing this is loading lean—including only the data and configuration you need to meet your business-critical operations. Lean Loading
  • Identifying the business-critical operations before moving users to Salesforce.
  • Identifying the minimal data set and configuration required to implement those operations.
  • Defining a data and configuration strategy based on the requirements you’ve identified.
  • Loading the data as quickly as possible to reduce the scope of synchronization.

Anti-Patterns for LVD

Design patterns in the context of computer science are proven, highly effective approaches to solving common challenges in software development. So it makes sense that an anti-pattern is the opposite of a design pattern: A software implementation of some sort that is suboptimal. There are few anti-patterns that cause a lot of problems:

  1. Formula Fields Unknowingly Slow Reports
    • Formula fields are a great tool when used in the proper context while understanding the scalability and response time implications for their usage. However, without a proper understanding of how they function, formula fields can sometimes come back to bite you.
    • Use a trigger to populate denormalized related fields that would facilitate blazing report/query performance without runtime joins.
  2. Full Database Backups are Slow
    • Use incremental data backups (only backing up the data that is new or updated) instead of the full backup. Also, use queries that filter records using SystemModstamp (a standard field in all objects that has an index) rather than the LastModifiedDate field (not indexed)
    • A full reload integration operation might use an unnecessarily high amount of Salesforce server resources, which could result in degradation in organization-wide processing performance, which could impact Bulk API jobs (or other data loading jobs), Dashboard and Report performance, Apex code (@future or batch Apex), and even general page performance.

LastModifiedDate and SystemModStamp?

Let’s recap what LastModifiedDate and SystemModStamp dates are. They are both system fields that store date and time values for each record.

  • LastModifiedDate is automatically updated whenever a user creates or updates the record. LastModifiedDate can be imported with any back-dated value if your business requires preserving original timestamps when migrating data into Salesforce.
  • SystemModStamp is strictly read-only. Not only is it updated when a user updates the record, but also when automated system processes update the record. Because of this behavior, it creates a difference in stored value where ‘LastModifiedDate <= SystemModStamp’ but never ‘LastModifiedDate > SystemModStamp’.

Approaches for Tuning Force.com Performance

  • Long-Term Approaches
    • Keeping Your Org Lean
    • Only store what’s needed.
    • Know your expected data growth rate and design accordingly
    • Define criteria for data archiving and purging. 
  • Short-Term Approaches
    • Use skinny table

What is Reference Data?

Reference Data as we know is the data used to categorize other data within applications and databases. We usually refer to this data as look-up, code table or domain values. These code tables are usually characterized by code and value pairs. Think of it as a set of allowed values for a given field.

Thursday, April 29, 2021

Time Conversion for different time-zone

The purpose of this article is to explain different methods of timezone classes, and how they can be used. Even though Salesforce used to convert the dates based on the logged-in user timezone, however, you wanted to see a time to a different timezone, you can do it with the TimeZone class. 

You can use below methods to calculate time in different time zones. 

TimeZone Methods

  1. getDisplayName() - Returns this time zone’s display name.
  2. getID() -Returns this time zone’s ID.
  3. getOffset(date) -Returns the time zone offset, in milliseconds, of the specified date to the GMT time zone.
  4. getTimeZone(timeZoneIdString) -Returns the time zone corresponding to the specified time zone ID.
  5. toString() -Returns the string representation of this time zone.

In the above methods, getOffset() method is very important. An offset is the number of hours or minutes a certain time zone is ahead of or behind GMT. A time zone’s offset can change throughout the year because of Daylight Saving Time.

User Case

Let’s say, there is a sales Rep, who calls customers and book appointments with experts to assist their needs. Suppose the Sales Rep is sitting in Dallas which is in Central time-zone and he called to a customer who is sitting in (New York Eastern time zone). While booking the appointment, the customer will suggest time as per his local time zone. In that case, sales Rep needs to convert time to his timezone. So if a user suggests 12 PM EST, it will be 11 AM CST. Using the below logic, sales rep no need to worry about this conversion. 

public static DateTime getConvertedTime(DateTime anyDateTime, string sourceTimezoneId, string targetTimezoneId){

        //get source time-zone corresponding to the specified time zone ID

        TimeZone sourceTimeZone = Timezone.getTimeZone(sourceTimezoneId); 

        //get source time-zone offset in milliseconds

        Integer sourceGMT_Time=sourceTimeZone.getOffset(anyDateTime);

        //get Target time-zone corresponding to the specified time zone ID

        TimeZone targetTimeZone = Timezone.getTimeZone(targetTimezoneId);

        //get target time-zone offset  in milliseconds

        integer targetGMT_Time = targetTimeZone.getOffset(anyDateTime);

        //Get the difference in milliseconds

        Integer differenceInMs = targetGMT_Time- sourceGMT_Time;

        //Convert difference into minutes    

        Integer differenceInSec= differenceInMs/1000;

        //Add difference to the time, to get time in target timezone

        DateTime timeInTargetTimeZone = anyDateTime.addMinutes(differenceInSec);

        return timeInTargetTimeZone;

}                         


Reference: Salesforce Documentation 

Friday, April 23, 2021

Schedule Event Monitoring

How to Schedule Event Monitoring in Salesforce Einstein Analytics?

  • Go to data manager 

        
  • Go to Dataflows & Recipes under Monitor
        
  • Go to Event Monitoring App and click on Schedule
        
  • Schedule the accordingly 
    

Thursday, April 15, 2021

Aura Interfaces

Interfaces define a component’s shape by defining attributes, events, or methods that any implementing component contains. 
  • To use an interface, a component must implement it.

  • An interface can’t be used directly in markup.

Types of Interfaces

Broadly, there are two types of Interfaces, one is in-build interface provided by framework which can be used for different and the other is a custom that developers can build themself.

In-build Interface

Theura framework provides in-build interfaces which you can implements in your custom component for different purposes. Below are a few in build interface:

  1. force:appHostable – The force:appHostable interface makes the component available for use as a custom tab. This interface is a marker interface. A marker interface is a signal to the component’s container to add the interface’s behavior to the component. You don’t need to implement any specific methods or attributes in your component, you simply add the interface name to the component’s implements attribute.

  2. flexipage:availableForAllPageTypes-To make your component available for record pages and any other type of page, implement the flexipage:availableForAllPageTypes interface.

  3. flexipage:availableForRecordHome- To make your component available for record pages only, implement the flexipage:availableForRecordHome interface.

  4. force:lightningQuickAction- Add the force:lightningQuickAction interface to a Lightning component to allow it to be used as a custom action

  5. forceCommunity:availableForAllPageTypes- To appear in Experience Builder, a component must implement the forceCommunity:availableForAllPageTypes interface.

  6. force:hasRecordId-Add the force:hasRecordId interface to an Aura 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 mobile app, and so on. This interface has no effect except when used within Lightning Experience, the Salesforce mobile app, and Aura-based Experience Builder sites.

You can find more build interface below: https://developer.salesforce.com/docs/component-library/overview/interfaces 

Custom Interface

You can create your own interface using <aura:interface> tag. An interface can contain only these tags:

  • <aura:attribute> tags to define the interface’s attributes.

  • <aura:registerEvent> tags to define the events that it may fire.

  • <aura: method> tags to define the events that it may fire.


<aura:interface>

    <aura:attribute name="value" type="String" />

    <aura:registerEvent name="onItemSelected" type="ui:response" description="The event fired when the user selects an item" />

    <aura:method name="methodFromInterface">

        <aura:attribute name="stringAttribute" type="String" default="default string" />

    </aura:method>

</aura:interface>