Skip to main content

Posts

Showing posts from 2018

Dynamically populate lightning:combobox

In order to dynamically populate values in lightning:combobox using javascript we can create a list variable and push the values. We also require the values like ids associated to the particular option for back-end logic. For example  : If we want to show the list of contacts using lightning:combobox component where the option should display the contact name but the value should be the contact id which will be used for back-end logic For this we can create a temporary Map variable in our lightning component and set the value and label parameters of the lightning:combobox. Here is the code for this component Combo.app <aura:application extends="force:slds" access="global" description="Lightning Combo Demo"> <c:Combo_Cmpt/> </aura:application> Combo_Cmpt.cmp <aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="ComboController"> <!-- ...

Salesforce CPQ Pricing Models

This post briefly covers the different pricing models which Salesforce CPQ has currently :- 1. Discount Schedule It has two types :-     a> Slab     b> Range Steps to implement :- - Create a discount schedule record , select slab or Range as type and Percent/Amount as discount unit. - Create discount tiers with the unit range. Tier Name  Lower Boundary Upper Boundary Discount(%) 1-10 Units 1 11 0 11-20 Units 11 21 5 21-30 Units 21 31 10 30+ Units 31 41 15  - Add this discount schedule to the Product you want to apply the pricing. Calculation :- if Type = Slab , List price = $100 and Quantity = 11 Total Price = Tier 1 Quantity * List Price * (1- Disc.%) + Tier 2 Quantity * List Price * (1- Disc. %)                   =  10 * 100 * (1-0)  + 1* 100 * (1-0.05)          ...

Upload files to Salesforce Feed using Chatter connect API and test using CURL

Have you ever came across a requirement to upload files to Salesforce feed from external system? If yes , here is a step by step approach to implement this use case. With lightning roll out Salesforce is converting attachments to files. Any attachment added also creates a file. Both files and attachment  are in sync , if you add/delete a record in file it will add/delete a attachment and vice versa. Gone those days when you couldn't  attach an attachment having size more than 5MB. With Files you have got the option to upload / attach a file up to 2 GB. In order to upload files from external system , we can use the Salesforce connector which is exposed using Enterprise WSDL and directly upload to Attachment records , which in turn creates a file record. In order to test it , you need to install cURL command prompt like CYGWIN Terminal. Here is the link to download it. Use these steps to test the flow using cURL. Step 1: Login using OAuth.(Create a connected ap...

Processing MultiPart/Form-Data file/Attachment using HTTP in Apex

If you need to process a file like images to some third party system using HTTP request in Apex , we need the Multipart/Form-data processing in the HTTP request. In this example I am using salesforce chatter Rest API to fetch the content of a file and then passing that file content to the HTTP request. This is just a sample code , you will have to enter the authorization tokens and endpoints. Please note that processing files /Attachments using this may cause heap size governor limit also it counts against your daily limit of outbound webservice (HTTP) calls.  1.Fetch File Content From Salesforce  Blob bodyBlob = null;  HTTPRequest req = new HTTPRequest();  req.setEndpoint('<YourInstance>/services/data/v43.0/connect/files/ fileId /content');  req.setMethod('GET');  req.setHeader('Authorization', 'Bearer  <Set oAuth Token>');  Http http = new Http();  HTTPResponse res = http.send(req);  bodyBlob = blob.valueO...

Salesforce Live Agent to your Service Console - Prechat Vs Custom Attributes

If are working on a Live Agent implementation for your client , you might come across certain circumstances where you will have to decide between using a Pre-chat form or embedding the custom attributes to get the parameters from the web-server or Portal it is deployed. PreChat  If your requirements has Pre-chat form then your life becomes easy , since Pre-chat form can be hosted on Salesforce VF page and it gives you more control over find or search record in salesforce , linking a record to another or automatically invoking the knowledge widget of Service Console based on the customer's problem description entered at pre-chat. Before using pre-chat , you will have to do some basic configurations like creating Buttons , deployment , setting up a chat user etc. Please follow the Salesforce Live Agent guide for configuring the same. A sample Pre-Chat form will like this. <apex:page showHeader="false">            ...

Account Search Lightning Component using lightning:datatable and KeyUp event Salesforce

In this post we will see how can we use the out-of-the-box lightning data table to show the account search result. This can be used in many place since search is a very common requirement. AccountSearch.cmp <aura:component controller="AccountSearchController" implements="force:appHostable,lightning:actionOverride,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:isUrlAddressable" access="global"> <aura:attribute name="data" type="Object"/>     <aura:attribute name="columns" type="List"/>     <aura:attribute name="selectedRows" type="List" />     <aura:attribute name="maxRowSelection" type="Integer" default="1"/>      <aura:attribute name="selectedRowsList" type="List" />     ...

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 ...