Skip to main content

Posts

Showing posts from June, 2018

Populate email body on custom CKEDITOR email editor in Salesforce.com

Other than using out-of-the-box Salesforce email editor , there are some scenarios where you need to build your custom email editor. You can build a custom email editor using CKEDITOR HTML editor. Once you build the custom editor , you will face the issue while fetching the body of the template. To display the email body in a HTML format from the predefined email templates , you can send the email using apex and then rollback immediately and fetch the email body in correct HTML format.  Here is the sample code :- Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); String toAddress = 'testemaildomain@test.com'; String templateId = '<Fetch Id of email template>' // Set the template id for which we need the HTML formatted body. email.setTemplateId(templateId); email.setWhatId(<Object Id>); email.setSaveAsActivity(false); email.setTargetObjectId(contactId); email.setToAddresses(new String[] {toAddress }...

Favorite / Follow Lightning Component using Bootstrap in salesforce.com

As you know Lightning uses a java-script based aura framework. It makes it very easy to plugin with any other java-script libraries like React and Bootstrap. Also , you can use popular analytics and map libraries like Leaflet and D2 Charts. In this example we will create a lightning component which will allow user to follow the records , this is different from salesforce's follow icon , as part of this component we will create a field (Follow) on Account Object , which will be checked if a user follows that record from Salesforce1 mobile app or web. We will use this bootstrap's " glyphicon "  icon. In this example you can also get familiar with how to use Application events , embed bootstrap and  JQuery in your lightning component. We will fetch few accounts from system and use this icon to follow the records. Here is how it will appear in Salesforce1 mobile app. Prerequisites :- 1. Download latest jQuery and add in static resource and ...

Customize Service Console Standard Feeds using Salesforce.com Chatter ConnectApi

Salesforce Service Console feeds gives a holistic view of all the actions happening on cases which your agents can refer for quick summary of all that is happening on that case. It is also useful when the cases are transferred to some other support agent. There is some limitations in the feed we see on service console which might require you to customize Since not all feed actions are in detail. For example if you see an email feed , it contains whole body of the email , where as a feed on a new case related object created will contain only the record name or auto-number by  default. Though you can add a compact layout for the object which will allow you to add more fields in the feed but here we have a limit of 255 character on each field. Example : Suppose you add these fields in case compact layout then these will appear in the feed where each field e.g Subject can contain maximum of 255 characters Case Number Subject Status These standard fee...

Chrome postman for Rest API testing using Salesforce OAuth 2.0 connected apps in Salesforce.com

For testing Rest APIs using Salesforce Connected app OAuth 2.0 configuration using CHROME Postman. Follow these steps. 1. Create a Connected App Go to -> your name -> setup -> App -> Connected App -> Click "new" Populated necessary access and details , it should looks like as per the screenshot below  You will get a consumer key ( Client_Id ) and a Consumer secret ( Client_Secret ) . Keep these information handy , we will need it while setting up OAuth in Postman. Important step : In your connected app make sure the Callback URL is :- https://www.getpostman.com/oauth2/callback 2. Setup Authorization in Chrome Postman Open the chrome postman client and create one request . Save it to any collection or create new. Select below configuration :- Method : POST  URL :  https://www.getpostman.com/oauth2/callback a.) Go to Authorization tab and select OAuth 2.0 and click "Get New Access Token" button ...

Multi Org spin out (Hub-Spoke) and Change Data Capture (CDC) in Salesforce.com

Why Multi Org ? Having all sales , service and marketing clouds on a single org is no more a good practice from overall Org strategy point of view. Having everything on one instance makes sense from data availability point of view but this is not more an excuse since near real time data can be access using various channels on Salesforce platform. Having everything in one org have some other limitations , to start with the governor limits which can be seen in terms of code character usage , data storage constraints , sharing related issues like hiding sales data to anyone else in the org who are not intended to know those. While moving Sales , Service & Marketing clouds into separate Orgs solves all these problems. Hub Org should be the Master Org where all the Orgs data is synced. This Org can be used for analytics purpose and also can act as backup database. There may be instances where Service cloud need to see sales cloud data. For example , Case ...

Update tab label on Salesforce Lightning Service.com Console

Records in Salesforce service console takes standard name or casenumber as default tab name. To override the default tab name , we can leverage console javascript tool kit by using getFocusedTabInfo() to rename the tab. For that we need to create a lightning component and add it to the lightning page of record in service console by editing the page ( Edit Page ). Here is the code of the lightning component. RenameTab.cmp (Component file) <aura:component controller="TabLabel" implements="flexipage:availableForAllPageTypes" access="global" >         <lightning:workspaceAPI aura:id="workspace" />          <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>     <aura:attribute name="case" type="Case" /> </aura:component> RenameTabContoller.js (Controller file) ({          doInit : function(component, event, h...

Send Push Notification on Salesforce1 Mobile app using apex in Salesforce.com

Salesforce chatter API has sends a Push notification to salesforce1 mobile app is we add a post and mention a user to it. The prerequisites are :- 1. User need to installed Salesforce1 mobile app on it mobile device. Google play  : https://play.google.com/store/apps/details?id=com.salesforce.chatter Apple store   : https://itunes.apple.com/app/id404249815?mt=8 2. The users's profile should have "Chatter enabled". Apex code for mentioning user on a chatter post :- Note : This code is works on class version : 33 , there might be change in method signature in latest versions.   // mentionIds - list of user ids who should recieve notification // recordId - Id of the record iof any // recordURL - custom record url public static void mentionChatter(String body, Id recordId , List<Id> mentionIds , String recordURL){          try{              if(body!=null && body!=...

Create dynamic object and fields drop-down in Salesforce.com

Allow user to create a filter rule for Out of office emails  in Salesforce.com There are many occurrence specially where we are enabling user to add dynamic rules , this requires us to replicate the product search screen where user can select an object where we can fetch the related field using dynamic apex and then add a pick-list where user can select the condition like EQUAL , INCLUDES. Which can be used to create rules which can be picked in Apex. Use case : Allow user to create a filter rule for Out of office email filter Here is the sample code to create this screen. Page :- <apex:page sidebar="false" controller="RuleManagerController">   <apex:sectionHeader subtitle="Rule Manager"/>   <style>       .slds-button--brand.slds-button { margin-bottom:0.5rem; color: #fff; border: 1px solid #0070d2; background: #0070d2; font-size: 1em; padding: 2px 3px;}   </style>   <script type...