Quick Demo - Salesforce Platform Events

Hi All,
I am going to show you all a quick demo which I have made using Salesforce Platform Custom Events. Follow below steps:

1) Create Custom Event object:
In setup -> Platform Events -> Create a new object lets say "Opportunity Status Event". Please see below picture for the same.



2) The purpose for this demo is to fire a event as soon as opportunity stage field value changed. So we need to write a trigger on Opportunity object. This trigger will fire a custom event for "Opportunity Status Event" using EventBus.Publish() method. Please check below code:

trigger OpportunityTrigger on Opportunity (after update) { list<Opportunity_Status_Event__e> eventList = new list<Opportunity_Status_Event__e>(); for(Opportunity opp: trigger.new){ if(opp.StageName != Trigger.oldmap.get(opp.id).StageName){ Opportunity_Status_Event__e statusEvent = new Opportunity_Status_Event__e(); statusEvent.record_id__c = opp.id; statusEvent.status__c = opp.StageName; eventList.add(statusEvent); } } if(eventList.size() > 0){ EventBus.publish(eventList); } }

3) Now, as you have created publisher. Now you need to make subscribers.

4) My first subscriber here is VF page called "OpportunityStatus". It shows all opportunity stage names in a graphical way, to make this graphic component, i took help from this site: https://codepen.io/anon/pen/MOJyQN



In this VF page, we need to subscribe our Custom Event which is fired from Opportunity Trigger. For subscribing it, I used "cometd". You can extract this library from internet or you can download all source code from bottom section of this blog. Please see following code:

<apex:page standardController="Opportunity" sidebar="false" extensions="OpportunityStatusController"> <script src="{!URLFOR($Resource.cometd,'cometd/cometd.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/jquery-1.5.1.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/json2.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/jquery.cometd.js')}"/> <apex:sectionHeader title="Opportunity Stage" subtitle="Indicator"/> <style> /* Form Progress */ .progress { text-align: center; } .progress .circle, .progress .bar { display: inline-block; background: #fff; width: 40px; height: 40px; border-radius: 40px; border: 1px solid #d5d5da; } .progress .bar { position: relative; width: 110px; height: 6px; margin: 0 -5px 17px -5px; border-left: none; border-right: none; border-radius: 0; } .progress .circle .label { display: inline-block; width: 32px; height: 32px; line-height: 32px; border-radius: 32px; margin-top: 3px; color: #b5b5ba; font-size: 17px; } .progress .circle .title { color: #b5b5ba; font-size: 13px; line-height: 30px; margin-left: -18px; } /* Done / Active */ .progress .bar.done, .progress .circle.done { background: #eee; } .progress .bar.active { background: linear-gradient(to right, #EEE 40%, #FFF 60%); } .progress .circle.done .label { color: #FFF; background: #8bc435; box-shadow: inset 0 0 2px rgba(0,0,0,.2); } .progress .circle.done .title { color: #444; } .progress .circle.active .label { color: #FFF; background: #0c95be; box-shadow: inset 0 0 2px rgba(0,0,0,.2); } .progress .circle.active .title { color: #0c95be; } .title{ white-space: nowrap; } </style> <div class="progress"> <apex:variable value="{!1}" var="index"/> <apex:repeat value="{!stageValues}" var="stage"> <div class="circle"> <span class="label">{!index}</span> <span class="title">{!stage}</span> <apex:variable value="{!index+1}" var="index"/> </div> <apex:outputPanel rendered="{!stage != 'Closed Won'}" styleClass="bar done"></apex:outputPanel> </apex:repeat> </div> <script> var i = 0; $('.progress .circle').removeClass().addClass('circle'); $('.progress .bar').removeClass().addClass('bar'); $(".progress .circle").each(function( index ) { if($(this).find(".title").text() == "{!currentStatus}"){ $(this).addClass("active"); i = 1; }else if(i == 0){ $(this).addClass("done"); } }); var j$ = jQuery.noConflict(); j$(document).ready(function() { j$.cometd.init({ url: window.location.protocol+'//'+window.location.hostname+'/cometd/41.0/', requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'} }); j$.cometd.subscribe('/event/Opportunity_Status_Event__e', function(message) { if(message.data.payload.Record_Id__c == "{!oppId}"){ j$('.progress .circle').removeClass("active"); j$('.progress .circle').removeClass("done"); i = 0; j$(".progress .circle").each(function( index ) { if(j$(this).find(".title").text() == message.data.payload.Status__c){ j$(this).addClass("active"); i = 1; }else if(i == 0){ j$(this).addClass("done"); } }); } }); }); </script> </apex:page>
In above code, you can see, as soon as it receives a event, it changes the indicator values on progress bar.

5) My second subscriber here is another VF page called "OpportunityStatusGraph". It shows current stage of opportunity in  a CSS Circle format with different colors.



It uses same way for subscribing event using "cometd" plugin. See the below code:

<apex:page standardController="Opportunity" sidebar="false" extensions="OpportunityStatusController"> <script src="{!URLFOR($Resource.cometd,'cometd/cometd.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/jquery-1.5.1.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/json2.js')}"/> <script src="{!URLFOR($Resource.cometd,'cometd/jquery.cometd.js')}"/> <apex:sectionHeader title="Opportunity Stage" subtitle="Indicator"/> <style> .circle { width: 300px; height: 300px; border-radius: 50%; font-size: 25px; color: #fff; line-height: 300px; text-align: center; background: #d9534f; } </style> <div class="circle">{!currentStatus}</div> <script> $(document).ready(function() { setcolor( $(".circle").text()); $.cometd.init({ url: window.location.protocol+'//'+window.location.hostname+'/cometd/41.0/', requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'} }); $.cometd.subscribe('/event/Opportunity_Status_Event__e', function(message) { if(message.data.payload.Record_Id__c == "{!oppId}"){ $(".circle").text(message.data.payload.Status__c); setcolor( $(".circle").text()); } }); }); function setcolor(circolor){ if(circolor == 'Prospecting') $(".circle").css("background-color","#f7f7f7"); else if(circolor == 'Qualification'){ $(".circle").css("background-color","#0275d8"); }else if(circolor == 'Needs Analysis'){ $(".circle").css("background-color","#5bc0de"); }else if(circolor == 'Value Proposition'){ $(".circle").css("background-color","#f0ad4e"); }else if(circolor == 'Perception Analysis'){ $(".circle").css("background-color","#d9534f"); }else if(circolor == 'Negotiation/Review'){ $(".circle").css("background-color","#292b2c"); }else if(circolor == 'Closed Won'){ $(".circle").css("background-color","#5cb85c"); } } </script> </apex:page>


5) This is the Apex Class code. This is straight forward code:

public class OpportunityStatusController{ public string oppId {get;set;} public string currentStatus {get;set;} public OpportunityStatusController(ApexPages.standardcontroller sc){ oppId = sc.getRecord().Id; currentStatus = [select id, stagename from opportunity where id=:oppId].StageName; } public List<String> getStageValues(){ Schema.DescribeFieldResult fieldResult = Opportunity.StageName.getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); List<String> options = new List<String>(); for( Schema.PicklistEntry f : ple){ options.add(f.getValue()); } return options; } }

Now, to see full demo of this functionality, check the video below:




Now, you can see, in salesforce we can fire any type of custom event using Platform Events feature. We can also have external apps or websites, which can subscribe these events and updates contents automatically. Like we can have custom web page on heroku or amazon or mobile app window which can subscribe these custom events and listen it.

We can think many other ways or ideas where we can utilize this amazing feature of salesforce.

Comment or drop email if you have any question or suggestion on this.

Downloads:
Static Resources

Thanks


AppExchange Quick Knowledge for Begginers


App Exchange
App Exchange provides a platform to offer marketing of your cloud computing applications and services. To provide you app on App exchange, you must be a salesforce partner.


App exchange generally provides a place to create, publish, install apps to salesforce. Let’s go through one by one,
Create : User initiates process to create app, by creating custom object, fields, layouts, tabs, pages, classes, reports and dashboards. These are the components which are shared with other users as an app on App exchange.
Publish : A salesforce user can publish their app on App exchange. To publish on exchange, they should be salesforce partner. They can tell about app to other users via documentation or videos.
Install : This is the last step of this process, salesforce users choose app from app exchange and install that app in their org. This is a simple process, just select an app and get it now, can install either in production (also in developer org) or in sandbox. You need to provide salesforce credentials, read user guide and install it then Done.


Who have rights to use App Exchange?

  1. Anyone can search and install apps from App Exchange.
  2. Users should have ‘Download AppExchange Packages’ permission to install apps.
  3. Users should have ‘Create AppExchange Packages’ and ‘Upload AppExchange Packages’ permission to publish app on App exchange.


Before installing a package what should we do?

  1. Always take a demo or test drive before installation.
  2. Also, check that according to application, you have sufficient requirements or not, means that app should be compatible with your org and system.
  3. Some time apps automatically provides push upgrades feature, means automatically upgraded in your system whenever new version is created.
  4. You can also uninstall packages if you needed.

Sometimes installation fails due to following reasons,

  1. In app package, there will be custom objects so may be possible that org’s custom object limit can exceed.
  2. In app package, there will be custom tabs so may be possible that org’s custom tabs limit can exceed.
  3. If you are trying to install an extension to a package, and you don't have the base (main) package installed in your org then it will fail.
  4. As per app requirement, may be possible that some components or settings should be turn on in your org, so that should be enable as required feature of an app.
  5. Package of app contains Apex code and you are not authorized to run Apex in your org.
  6. Package can contain a failing test class.


How to publish an app on exchange?

To publish an app, component on the AppExchange, follow these steps,
  1. In which org, your package is created, connect this org to AppExchange.
  2. Create a profile for provider.
  3. Give some documentation or videos to tell customers about your app or product.
  4. Create the listing.
  5. If you have app or component, then submit business plan for review.
  6. If you have app or component, then submit the package for security review. Whenever approved by salesforce then you can publish. This is the major part of publish process.
  7. After your app is approved by salesforce, publish the listing on the AppExchange.
  8. Review about your app, how that’s performing.


AppExchange in salesforce



Top 10 popular apps on App Exchange,

http://www.salesforceben.com/top-10-popular-appexchange-apps/


  1. Mass Update & Edit :  Select records from an list view or related list and update them using multi-line editor. Also, can do mass transfer records, set a field to an empty value.
  2. LinkPoint Connect :  In Outlook, you can view/create salesforce data like Contact, lead and opportunity and case records, inbound/outbound emails to salesforce.
  3. Docusign : It’s Lightning ready app with latest salesforce technology. It’s used for e-signature on documents which save time and also provides workflows and data update feature, that also save time to write in apex trigger.
  4. Cirrus Insight : This app gives ability to interact with Salesforce in your inbox. Using this app, we can sync emails, calendar and view Salesforce data all within inbox.
  5. MailChimp : Used to send emails, manage mailchimp subscribers from salesforce leads, contacts and list view. Also, can upload to leads, can see subscriber activity history in salesforce.
  6. dataloader.io :  This is also most useful app to do DML in salesforce data, just login in salesforce and download records or perform any DML in salesforce. You need to upload data in csv file format. Also, provides search filter and save filter, auto mapping facility.
  7. Conga Composer :  This app is used to send documents also save time to prepare and edit that document. Also, reduce error in typing and you can also can fetch data from salesforce easily.
  8. Ebsta : Used to sync gmail/google calendars, also supports multiple time zones, meeting updates and events which are upcoming and delete events which are out of box. Also, can see status of message, it’s read, ignored or not opened.
  9. Data.com Assessment App :  It’s used for data quality and field level details to show that where are gaps that need to be addressed. And match that how can improve it.
  10. Salesforce Adoption Dashboards : This provides details about user login history and adoption of key salesforce.com feature, sales and marketing productivity.

Hope you like the information.

Thanks



Salesforce Quick Access and Backup

Hi Guys,

Me and my friend Akhil Mandiya developed an extension "Quick access and Backup" for salesforce users/developers.

By using Quick access and backup salesforce user can easily access the component and take backup quickly.

This extension enables three major features:

1. Quick-Backup while coding: It will provide a context menu "Download File" option on Visualforce Pages, Apex Class, Visualforce component, and trigger. By this option, you can take backup of these components while writing code or viewing code.


2. Quick-Access: Here you can search and jump to a particular Apex Class, VisualForce Page, Apex trigger, Workflow and Email- templet also you can take backup of that component.



3. Backup: It provides the list of pages, components, triggers, and classes from your org. Here the user can select the components and download.


Please download by clicking below link and share your feedback:

https://chrome.google.com/webstore/detail/quick-access-and-backup/elphfagjcohjcfblfidejpiolkocfkhd

Thanks and regards
Rohit Sethi

rohit.sethi@ibirdsservices.com

Salesforce Mass Email AppExchange Product

Hi All,

I have created an Salesforce app for App Exchange  for Mass Email, This app is used to send mass emails to Standard/Custom Objects in which Email field exist. You can also set filters on records and customize your columns here. Also, can select recipient type, and email template. Send emails NOW or in FUTURE.


  • Mass Email to any Standard/Custom object in which Email field exist. Easy to use and user friendly process.
  • Provide Customization filters, Email Template, Recipient Type. Customize columns and search experience as well.
  • We can schedule sending email either on-spot or in future.


Lightning design used and would be beneficial for developers and admins to send emails in bulk, also they can select filters on records and customize columns to see values. You can select recipients of mails i.e. Owner, email field etc. Also can select email template, and can see preview of email template, using separate folders. Also, can start sending emails NOW or in FUTURE, can select Date and Time here, also provide name of Mass Email. If you use Schedule for future, then will set scheduler for given time.












You can download from Appexchange : 

Install this app into your org and let me know for more enhancements or drawbacks, i am looking forward to provide you usable product. Please provide Rating also.

You can provide your feedback on my email ranu@ibirdsservices.com. 

Thanks