Skip to main content

Posts

Restricting Salesforce username and password login for non administrators

 In this post, We are going to see on how to restrict username/password login using Delegated authentication. Use Case: When the SSO is implemented in the organisation, Admin may want to restrict the users using a Salesforce username and password for login, so that the user always use SSO to login. To achieve this requirement in Salesforce, We are going to use Delegated authentication. Step 1: Enabling Delegated Authentication In Lightning, Go to Gear Icon > Setup > Look for Single Sign-On Settings in Quick Find > Under Delegated Authentication, select Disable login with Salesforce credentials . Once you select this option, The UI will be shown like this We don’t need to configure ‘ Delegated Authentication URL ’ and ‘Force Delegated Authentication Callout ’ for this implementation. Step 2: Enabling Delegated SSO at related Profile or Permission Set Enabling the Delegated SSO will add " Is Single Sign-On Enabled " permission at ...

When to use UserRecordAccess and ObjectShare object Salesforce

 Let us quickly see the differences between these objects, use cases, restrictions and finally why objectshare should not be used to get the access level of user in record. UserRecordAccess What is it : This object can be used to find out the user's access to a set of records. The important fields in this object are RecordId, MaxAccessLevel, HasReadAccess, HasEditAccess, HasDeleteAccess, HasDeleteAccess, HasTransferAccess and HasAllAccess. Use Case : As an admin, When you want to find out if the record can be accessed by the user or not, Or what level of access the user has on the record, This is object that will give the answer. Availability : API version 24.0 or higher. You can only query records of objects listed on the Sharing Settings Setup page. DML Restrictions: The object is Read only. We can’t create, delete, or update any records using this object. We can query maximum of 200 records at a time. When querying, Some special restrictions are a...

Logic to convert 15-character id to 18-character id Salesforce

 As we all know, Salesforce supports both 15-character id and 18-character id. Before API version 2.0, Salesforce supported only Case sensitive id. From API version 2.0 and higher, Salesforce is supporting both 15-character Case sensitive id and 18-character case insensitive id. Currently Salesforce provides some built-in options to convert the 15-character id and 18-character id. UI Creating a formula field on the object with function CASESAFEID(Id) to get the 18-char id at the record level. Apex / API When inserting or updating the records, Both 15 character id and 18 character id are accepted. Salesforce internally converts 15 character id to 18 character id to perform the operation. When querying the records, System always export the records in 18 character id. So Apex script using System.debug() or Simple API query using Developer Console or Workbench can show you 18-character id. Now coming back to actual question how to convert the 15-character id to 18 chara...

Governor Limit exception due to Rollup Summary Field Change

 Rollup Summary Field(RSF) gives an easy way to get values from related records when the two objects are related via Master -detail relationship. We can perform different types of calculations with a roll-up summary field such as count, sum, minimum value, or maximum value of a field in the detail records. I am sharing one of the platform behaviour noticed with Rollup Summary field calculation. When RSF definition is changed with an aggregated Field, Filter and Type , It will trigger Field Recalculation. When the currency conversion rates are changed, The currency fields are recalculated. As an admin, you have two options on field calculations. "Automatic calculation" option is to let salesforce decide the best time to run field Calculation. "Force a mass recalculation" option is to initiate the field calculation immediately. Whenever the field definition is changed, Depends on the calculation option selected, A background job with Type 'S...

Lightning Flow redirection to any URL with Local Action

One of the common requirements in lightning flow is to redirect to a record or to any random url after the flow is completed. In Lightning experience, This redirection can be achieved with a Local Action. We can redirect the user to any record or any URL such as tab, Related List and external URL etc. The implementation is a two step process. Create or Install the local Action to do the redirection. Add the local action to your flow with Core Action Element and pass the input to the local action. In the following example, We are creating a simple lightning flow which takes the URL as the input and redirect the user to the URL Step 1: Creating Local Action Flow Local Action calls a lightning component to achieve this redirection. Let us quickly see how this lightning component looks like navigateToUrl.cmp <aura:component implements="force:lightningQuickAction, lightning:availableForFlowActions"> <aura:attribute name="redirectURL" type="String" ...

Inserting Line breaks in Apex email message Salesforce

 To insert line breaks with setPlainTextBody method from SingleEmailMessage, Use '\n' character. Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setPlainTextBody('Hi \n \n' + 'Welcome to Gavan'); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); To insert line breaks with setHtmlBody method from SingleEmailMessage, use <br> tag Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setHtmlBody('<html><body>Hi <br/><br/>'+'Welcome to Gavan </body></html>'); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 

Embed Wave in Any Web Page or Web-Based App using Lightning out

 Embed Wave in Any Web Page or Web-Based App using Lightning out   As per the salesforce document Embed Dashboards Everywhere ,To embed Analytics in any web page or web-based app,   First, We need to add an Analytics dashboard component to your site, using Visualforce embedding, Lightning App Builder, or Lightning Out. This code sample shows how to add an Analytics dashboard component via Lightning Out. $Lightning.use("wave:waveApp", function() { $Lightning.createComponent("wave:waveDashboard", { dashboardId: "0FKxx00000006bOGAQ" }, "app"); }, url, accessToken) Second, set up a whitelist using the Content Security Policy (CSP). See Set Up a Whitelist of Trusted Sites for Embedded Analytics Dashboards. The whitelist for embedded Analytics includes the following by default: *.salesforce.com:* *.force.com:* Your org’s custom domain. However while implementing the above code, We might face some errors regarding CORS or Lightning errors eve...

Invalid_grant Authentication Failure in Username-Password Oauth flow

Sometimes the delegated authentication is configured in the customer's org for the logged-in user. So when the username and password is given during login, the authentication will be done via delegated authentication server, not by salesforce. We have seen a strange behavior in Username-Password OAUTH flow (Sept 6, 2018) when the request is made from API and Apex. 1. When OAUTH request made via api, You can pass external auth server password. grant_type:password username:username@gmail.com password:password  // This can be external system password client_id:3MV***log.W client_secret:65***58 2. When OAUTH request made via apex, The password should be salesforce password along with security token. If the external system password is given, you will get the below error 13:26:23.1 (5805772)|CALLOUT_REQUEST|[74]|System.HttpRequest[Endpoint=https://****.my.salesforce.com/services/oauth2/token, Method=POST] 13:26:23.1 (357570230)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:952 13:26:23.1 (357762371)|CA...

Sales flow : From Lead to Quote Process in Salesforce

 A lead is someone who is interested in the products or services from your organization. These leads in salesforce are generated via Campaigns, Content Marketing, Seminars and Advertising etc. Technically in Salesforce, Leads are created via 1. Manual creation 2. Bulk File import 3. Social Media 4. Out-of-Box functionality such as Web-to-Lead or Email to Lead 5. Email Services 6. Live Agent (Chat sessions) 7. CTI integration (Tele Sales) 8. Integration from other Systems Once the lead is qualified, It can be converted into Salesforce Account, Contact and Opportunity . Account, Contact and Opportunity :  Account is a company or a person with whom your company has relationship. Contact represents a person from the account we have relationship. An opportunity represents a prospective sale and it contains relevant sales data. Once opportunity is created and it has to go through various stages before it is closed. These stages can be customized as per our company needs. The ...

Salesforce OAUTH Error "We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator"

 Salesforce oauth_error_code=1800 is generic error which say OAuth flow has been broken. The below list contains a few reasons when we see this error message 1. Sometimes corrupted cookies can cause this issue. Test the OAUTH flow by clearing cookies or using Private window of the browser. 2. Time out issue : Oauth login has 15-30 minutes of grace period during which Oauth approval process has to be completed. Otherwise this error can happen.  3. Lack of necessary permissions such as API, Apex, Visualforce permissions for the user 4. If OAuth and SAML is involved with the flow, The error usually indicates that there is relayState issue. 5. Any other internal server error at Salesforce platform which can be solved by raising the case with Support.