Showing posts with label Abhi Tripathi. Show all posts
Showing posts with label Abhi Tripathi. Show all posts

Sunday, 19 August 2018

Best in Market - List of Code Review tools #Salesforce

Salesforce is an awesome platform, and has an incredible community that helps their developer and admins to grow in their careers. With Salesforce’s communities we get a lot of great tools which make developer and admin life easy. One of the important practices in project implementation is code review, as it insures your team has visibility into your applications code. Here is the list of few tools which I have found to help review codes:





1 Checkmarx : 



Checkmarx provides an awesome tool to secure your apex and visualforce code as well. It's easy to integrate with your salesforce org and provides you a whole report.
Report has the points of changes and what to changes, I personlly recommend this tool for your application and code security.
https://www.checkmarx.com/

2. Codescan: 



Code Analysis Tools for Salesforce
Its an appexchange tool which is really easy to use and install in your salesforce org. It help developers to identify bugs and increase the quality of your code.
This tool provides incredible UI to analyse you orgs apex code.
https://www.codescan.io/ 



3. PMD source code analyzer :



 PMD is also of the recommended tool to use for your apex code, its easily catches the defects of your apex code and provide you how to get ride of those defects.
It searches the unused variables, empty catch blocks, unnecessary object creation. This tool really help to clean your code in apex as well as in Javascript and visualforce.
https://pmd.github.io/ 

4. Clayton : 




Clayton is a next gen tool which does everything when you need your Salesforce application to be the best. It's very easy to setup and use. 
Clayton integrates into your code repositories and enforces quality and security standards across your organisation, at all times, while your apps are built. It provides you analyses over not only apex but lightning component code as well.
https://www.getclayton.com/ 

5. Code Climate :




 It Automated code review for test coverage, maintainability and more so that you can save time, it provides you real time feedback of your code that help to maintain
 good code as you go. It provides test coverage line by line as well, integrated with your GitHub repo, run analysis locally and team management with permission visibility.

 https://codeclimate.com/ 


Tuesday, 29 May 2018

Difference between Application Events and Component Events in Lightning #Salesforce

Component Events

A component event is fired from an instance of a component. A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event. The component that fires an event is known as the source component.



The component that fires an event can set the event’s data. To set the attribute values, call event.setParam() or event.setParams().

Fire a component Event

In terms of firing an event you need to register that component event in your component and then you can fire the same. it looks something like below



A component can handle its own event by using the <aura:handler> tag in its markup. The name attributes in <aura:registerEvent> and <aura:handler> must match, since each event is defined by its name.



Application Events

Application event in simple words can be used in multiple components and component that has the handler for the event will be notified.



To create a custom application event, you need to use the <aura:event> tag in the event resource. You need to define type="Application" tag. To use you need to register application event same way as component event



To fire the application event you need to use event.setParam();



Events are of the most widely used in lightning component. so when you should use which one is also important.

thanks

Tuesday, 22 May 2018

Converting Curl Request into Apex HTTP Request #Salesforce

Recently in a project I was working with a requirement, where we need to integrated Salesforce with that system, when I started going through the API documentation of the another system, they have provided everything with the curl request and response was in JSON.




So many of you guys might have already explored curl and converting the request as per another system requirement, but for me this was the first time. So if any of you have better approach then the one I am going to explain, please let me know.

So What is Curl ?

"cURL is a command line tool for getting or sending files using URL syntax.
Since cURL uses libcurl, it supports a range of common Internet protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP.
cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. When cURL connects to a remote server via HTTPS".

Wiki Link

So here is of the curl request that I was dealing with, and I have taken a normal one which can be easily converted to apex.


So in above request the main thing to be taken care is to identify the parameter, header, body, method and endpoint. To identify these you need to look for -X -u -d -H

-x stands for request method
-u stands for authorization header
-d stands for body of the request
-H also stands for header

So by knowing the parameter defined in the curl request you can easily and quickly create a request in apex. So the request in apex format looks like below




So here is an small description of curl request formatting.
Thank you!

Thursday, 8 February 2018

Caching Data with Storable Actions #Lightning Component Salesforce

Caching data at the client side can significantly reduce the number of server round-trips and improve the performance of your Lightning components. Server actions support optional client-side caching, and the Lightning Data Service is built on top of a sophisticated client caching mechanism.

In Lightning terminology, a server action is an Apex method that you invoke remotely from your Lightning Component. A storable action is a server action whose response is stored in the client cache so that subsequent requests for the same server method with the same set of arguments can be accessed from that cache.



Storable actions are the only currently supported type of storage. Storable actions cache server action response values. The storage name must be actions. Caching is especially beneficial for high-performance, mostly connected applications operating over high latency connections, such as 3G networks When you initialize storage, you can configure the expiration time, which is the duration in seconds that an entry is retained in storage..

Using storable actions, the cache behavior is controlled by two parameters set internally in the framework :
  • Expiration age: This is the age of the cached response. Whenever the response is older then the existing one and same vice versa. Expiration age is currently set to 900 seconds in Salesforce lightning.
  • Refresh age: Refresh age is the age of the response, when it gets refreshed, if the response is newer then the existing one, it will override the response, but lightning also calls the server method and get the response, if it different then the existing then it will override it as well. Refresh age is 30 second in lightning experience.

what to cache ?

The caching of the data should be decided on what is the response of your action, there are two type of action, one which returns everytime same thing, and another one is which is doesn't return the same response or dynamic.

The method which returns the same response each time called should be cached and other not,The setStorable function takes an optional argument, which is a configuration map of key-value pairs representing the storage options and values to set.

Cache Miss

If the action is not a cache hit as it doesn’t match a storage entry:
  • The action is sent to the server-side controller.
  • If the response is SUCCESS, the response is added to storage.
  • The callback in the client-side controller is executed.

Cache Hit

If the action is a cache hit as it matches a storage entry:
  • The callback in the client-side controller is executed with the cached action response.
  • If the response has been cached for longer than the refresh time, the storage entry is refreshed. When an application enables storable actions, a refresh time is configured. The refresh time is the duration in seconds before an entry is refreshed in storage. The refresh time is automatically configured in Lightning Experience and the Salesforce mobile app.
  • The action is sent to the server-side controller.
  • If the response is SUCCESS, the response is added to storage.
  • If the refreshed response is different from the cached response, the callback in the client-side controller is executed for a second time..

How to enable Storage Actions ?

To configure client-side storage for your standalone app, use <auraStorage:init> in the auraPreInitBlock attribute of your application’s template. For example:. 


<aura:component isTemplate="true" extends="aura:template">
    <aura:set attribute="auraPreInitBlock">
        <auraStorage:init
          name="actions"
          persistent="false"
          secure="true"
          maxSize="1024"
          defaultExpiration="900"
          defaultAutoRefreshInterval="30" />
    </aura:set>
</aura:component>


Thanks

Friday, 22 September 2017

Winter'18 - Basic Visualforce is now Ready for Lightning View #Salesforce

In this winter 18 release, Salesforce has upgraded what was required, now even if you are new to SLDS, no need to worry about as Salesforce have introduced "lightningStylesheets" tag just to make your life easy.
Designing in lightning sometime you need to search the class name and then add it your page to check whether its the same that you want.

So here is a simple demo of the old style visualforce page having all the things that we might use, and using the same visuaforce page in Lightning by changing nothing. Everything will taken care by salesforce just by using lightningStylesheets.
I have added almost all type of fields as well just to show how it looks without adding any further styling.

Take a look how it works





Here is the Visualforce page



Some good guy said


Thank you!

Monday, 11 September 2017

Using lightning:tree to display Account Hierarchy #Salesforce Lightning Component #Winter'18

 Winter'18 Salesforce have added a new lightning component called lightning:tree, using this we can display the hierarchy of Salesforce.

In this component is going to be great help to all the devs, when they want achieve the accordion looking hierarchy displaying component. This component support only version 41.0 and above



Here is the working demo



So in this post we have a small component which displays the account hierarchy upto 3 levels, I am not further on achieving the hierarchy of Account using Apex, so I did what I can using just a single SOQL.

Here is the component code

 <aura:component controller="LightningTreeApexController" implements="flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader,force:hasRecordId"> >  
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" />  
   <aura:attribute name="items" type="Object"/>  
   <aura:attribute name="recordId" type="String"/>  
   <lightning:tree items="{! v.items }" header="Account Hierarchy" onselect="{!c.handleSelect}"/>  
 </aura:component>  

Here Lightning component Controller code

 ({  
   doInit: function (cmp, event, helper) {  
     helper.apexMethod(cmp);  
   },  
   handleSelect: function (cmp, event, helper) {  
     //return name of selected tree item  
     var myName = event.getParam('name');  
     alert("You selected: " + myName);  
   }  
 })  


Here is the helper code

 ({  
   apexMethod : function(cmp) {  
     var action = cmp.get("c.getAccountHierarchy");  
     action.setParams({ accountId : cmp.get("v.recordId") });  
     action.setCallback(this, function(response) {  
       var state = response.getState();  
       if (state === "SUCCESS") {  
         cmp.set( "v.items", response.getReturnValue());  
       }  
     });  
     $A.enqueueAction(action);  
   }  
 })  


Here is Apex Controller


 public class LightningTreeApexController {  
     
   @AuraEnabled  
   public static List<items> getAccountHierarchy(Id accountId) {  
       
     //Wrapper instance  
     List<items> finalWrp = new List<items>();  
       
     //Going upto 2 level only as per SOQL limit  
     for(Account acc : [ Select Id, Name, Type, ParentId, Parent.Name, Parent.Type, Parent.ParentId, Parent.Parent.Name, Parent.Parent.Type From Account Where Id =: accountId]) {  
         
       //populating wrapper  
       List<items> trP1 = new List<items>{new items(acc.Type, acc.Name, false, null)};  
       List<items> trP2 = new List<items>{new items(acc.Parent.Type, acc.Parent.Name, false, trP1)};  
       finalWrp.add(new items(acc.Parent.Parent.Type, acc.Parent.Parent.Name, false, trP2));  
     }             
        
     System.debug('finalWrp:::' + finalWrp);  
     // return wrapper  
     return finalWrp;    
   }  
 }  


Here is wrapper class used in Apex controller

 public class items {  
     
   @AuraEnabled  
   public string label { get; set; }  
     
   @AuraEnabled  
   public string name { get; set; }  
     
   @AuraEnabled  
   public Boolean expanded { get; set; }  
     
   @AuraEnabled  
   public List<items> items { get; set; }  
     
   public items( String name, String label, Boolean expanded, List<items> items) {  
     this.label = label;  
     this.name = name;  
     this.expanded = expanded;  
     this.items = items;   
   }  
 }  


Some important links to learn more about Winter'18 Release


Salesforce Documentation


Lightning Design System : Lightning Tree


Salesforce Release Notes Winter'18



Thanks you

Sunday, 20 August 2017

Lightning Data Service - Salesforce Lightning Remote Objects

Lightning Data Service is in Beta, we can use lightning data service to create, upload, delete and edit salesforce object, without using apex controller, that is it is kind of Remote object that we have for salesforce visualforce page.

As it is beta, so many upgrades will be coming in future, Data access with Lightning Data Service is simpler than the equivalent using a server-side Apex controller. Read-only access can be entirely declarative in your component’s markup. It’s built on highly efficient local storage that’s shared across all components that use it. Records loaded in Lightning Data Service are cached and shared across components. Components accessing the same record see significant performance improvements, because a record is loaded only once, no matter how many components are using it.

here is a small and simple exam of lighting data component for creation of Contact record.





Here is the component code
 <aura:component implements="flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader,force:hasRecordId">  
   <aura:attribute name="account" type="Object"/>  
   <aura:attribute name="simpleAccount" type="Object"/>  
   <aura:attribute name="accountError" type="String"/>  
   <force:recordData aura:id="accountRecordLoader"  
     recordId="{!v.recordId}" fields="Name,BillingCity,BillingState" targetRecord="{!v.account}"  
     targetFields="{!v.simpleAccount}" targetError="{!v.accountError}"/>  
   <aura:attribute name="newContact" type="Object" access="private"/>  
   <aura:attribute name="simpleNewContact" type="Object" access="private"/>  
   <aura:attribute name="newContactError" type="String" access="private"/>  
   <force:recordData aura:id="contactRecordCreator"  
     layoutType="FULL" targetRecord="{!v.newContact}"  
     targetFields="{!v.simpleNewContact}" targetError="{!v.newContactError}" />  
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>  
   <!-- Display a header with details about the account -->  
   <div class="slds-page-header" role="banner">  
     <p class="slds-text-heading--label">{!v.simpleAccount.Name}</p>  
     <h1 class="slds-page-header__title slds-m-right--small slds-truncate slds-align-left">Create New Contact</h1>  
   </div>  
   <!-- Display Lightning Data Service errors, if any -->  
   <aura:if isTrue="{!not(empty(v.accountError))}">  
     <div class="recordError">  
       <ui:message title="Error" severity="error" closable="true">  
         {!v.accountError}  
       </ui:message>  
     </div>  
   </aura:if>  
   <aura:if isTrue="{!not(empty(v.newContactError))}">  
     <div class="recordError">  
       <ui:message title="Error" severity="error" closable="true">  
         {!v.newContactError}  
       </ui:message>  
     </div>  
   </aura:if>  
   <!-- Display the new contact form -->  
   <lightning:input aura:id="contactField" name="firstName" label="First Name" value="{!v.simpleNewContact.FirstName}" required="true"/>  
   <lightning:input aura:id="contactField" name="lastname" label="Last Name" value="{!v.simpleNewContact.LastName}" required="true"/>  
   <lightning:input aura:id="contactField" name="title" label="Title" value="{!v.simpleNewContact.Title}" />  
   <lightning:input aura:id="contactField" type="phone" name="phone" label="Phone Number"   
            pattern="^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$"  
            messageWhenPatternMismatch="The phone number must contain 7, 10, or 11 digits. Hyphens are optional."  
           value="{!v.simpleNewContact.Phone}" required="true"/>  
   <lightning:input aura:id="contactField" type="email" name="email" label="Email" value="{!v.simpleNewContact.Email}" />  
   <lightning:button label="Cancel" onclick="{!c.handleCancel}" class="slds-m-top--medium" />  
   <lightning:button label="Save Contact" onclick="{!c.handleSaveContact}" variant="brand" class="slds-m-top--medium"/>  
 </aura:component>  

Controller code

 ({  
   doInit: function(component, event, helper) {  
     component.find("contactRecordCreator").getNewRecord(  
       "Contact", null, false,   
       $A.getCallback(function() {  
         var rec = component.get("v.newContact");  
         var error = component.get("v.newContactError");  
       })  
     );  
   },  
   handleSaveContact: function(component, event, helper) {  
     if(helper.validateContactForm(component)) {  
       component.set("v.simpleNewContact.AccountId", component.get("v.recordId"));  
       component.find("contactRecordCreator").saveRecord(function(saveResult) {  
         if (saveResult.state === "SUCCESS") {  
           var resultsToast = $A.get("e.force:showToast");  
           resultsToast.setParams({  
             "title": "Contact Saved",  
             "message": "The new contact was created."  
           });  
           $A.get("e.force:closeQuickAction").fire();  
           resultsToast.fire();  
           $A.get("e.force:refreshView").fire();  
         }  
       });  
     }  
   },  
   handleCancel: function(component, event, helper) {  
     $A.get("e.force:closeQuickAction").fire();  
   },  
 })  

Helper code

 ({  
   validateContactForm: function(component) {  
     var validContact = true;  
           var allValid = component.find('contactField').reduce(function (validFields, inputCmp) {  
       inputCmp.showHelpMessageIfInvalid();  
       return validFields && inputCmp.get('v.validity').valid;  
     }, true);  
     if (allValid) {  
       var account = component.get("v.account");  
          return(validContact);   
     }   
      }  
 })  

This component you can use in Account Object detail page layout, and then try creating a contact record.
There are few things to keep in mind before thinking to use to Data service,


  • Can't be use for multiple records or mass DML's
  • Only available in Lightning & Salesforce1
  • Not all objects are supported by Lightning Data Service, listed in the link
Thanks


Tuesday, 25 July 2017

Salesforce Certified Data Architecture & Management Designer #SharingExperience

Its been a month since I added this certification in my list, this is one of the designer exam which I wanted to give in the first place, its averagely complex but not much difficult. So if you have atleast 4 years of salesforce experience that includes Data management practice, and experience with high volume data handling, then a little brush up of work can make you pass this certification.

This blog post is all about thing to cover up before going for the exam.




The Salesforce Certified Data Architecture and Management Designer candidate has the experience, skills, and knowledge of:

  • Data modeling/Database Design o Custom fields, master detail, lookup relationships o Client requirements and mapping to database requirements 
  • Standard object structure for sales and service cloud o Making best use of Salesforce standard objects 
  • Association between standard objects and Salesforce license types 
  • Large Data Volume considerations o Indexing, LDV migrations, performance
  • Salesforce Platform declarative and programming concepts 
  • Scripting using those tools (Data loader, ETL platforms) 
  • Data Stewardship 
  • Data Quality Skills (concerned with clean data)


Overview : 
  • Content: 60 multiple-choice/multiple-select questions* (2-5 unscored questions may be added) 
  • Time allotted to complete the exam: 90 minutes (time allows for unscored questions) 
  • Passing Score: 67% 
  • Registration fee: USD 400, plus applicable taxes as required per local law 
  • Retake fee: USD 200
Here are some key study points to cover before going for the exam :

PK Chunking Header

Use the PK Chunking request header to enable automatic primary key (PK) chunking for a bulk query job. PK chunking splits bulk queries on very large tables into chunks based on the record IDs, or primary keys, of the queried records. Each chunk is processed as a separate batch that counts toward your daily batch limit, and you must download each batch’s results separately. PK chunking is supported for the following objects: Account, Campaign, CampaignMember, Case, Contact, Lead, LoginHistory, Opportunity, Task, User, and custom objects. PK chunking works only with queries that don’t include SELECT clauses or conditions other than WHERE.
PK chunking is designed for extracting data from entire tables, but you can also use it for filtered queries. Because records could be filtered from each query’s results, the number of returned results for each chunk can be less than the chunk size. Also, the IDs of soft-deleted records are counted when the query is split into chunks, but the records are omitted from the results. Therefore, if soft-deleted records fall within a given chunk’s ID boundaries, the number of returned results is less than the chunk size.

Multitenancy and Metadata 


Multitenancy and Metadata Overview 
Multitenancy is a means of providing a single application to multiple organizations, such as different companies or departments within a company, from a single hardware-software stack. Instead of providing a complete set of hardware and software resources to each organization, Salesforce inserts a layer of software between the single instance and each organization’s deployment. This layer is invisible to the organizations, which see only their own data and schemas while Salesforce reorganizes the data behind the scenes to perform efficient operations. Multitenancy requires that applications behave reliably, even when architects are making Salesforce-supported customizations, which include creating custom data objects, changing the interface, and defining business rules. To ensure that tenant-specific customizations do not breach the security of other tenants or affect their performance, Salesforce uses a runtime engine that generates application components from those customizations. By maintaining boundaries between the architecture of the underlying application and that of each tenant, Salesforce protects the integrity of each tenant’s data and operations

Skinny Tables 

Salesforce creates skinny tables to contain frequently used fields and to avoid joins, and it keeps the skinny tables in sync with their source tables when the source tables are modified. To enable skinny tables, contact Salesforce Customer Support. For each object table, Salesforce maintains other, separate tables at the database level for standard and custom fields. This separation ordinarily necessitates a join when a query contains both kinds of fields. A skinny table contains both kinds of fields and does not include soft-deleted records. This table shows an Account view, a corresponding database table, and a skinny table that would speed up Account queries.
  • Skinny tables can contain a maximum of 100 columns. 
  • Skinny tables cannot contain fields from other objects. 
  • For Full sandboxes: Skinny tables are copied to your Full sandbox organizations, as of the Summer '15 release. Previously, they were not. 
For other types of sandboxes: Skinny tables are still not copied to your sandbox organizations. To have production skinny tables activated for sandbox types other than Full sandboxes, contact Salesforce Customer Support.


INDEX TABLES

The Salesforce multitenant architecture makes the underlying data table for custom fields unsuitable for indexing. To overcome this limitation, the platform creates an index table that contains a copy of the data, along with information about the data types. The platform builds a standard database index on this index table, which places upper limits on the number of records that can be returned more effectively by an indexed search. 

Force.com Bulk API

The REST-based Bulk API was developed specifically to simplify the process of uploading large amounts of data. It is optimized for inserting, updating, upserting, and deleting large numbers of records asynchronously by submitting them in batches to Force.com, to be processed in the background.
Uploaded records are streamed to Force.com to create a new job. As the data rolls in for the job it is stored in temporary storage and then sliced up into user-defined batches (max of 10,000 records). Even while your data is still being sent to the server, the Force.com platform submits the batches for processing.


Using the Bulk API and Monitoring Jobs

The Salesfore.com Data Loader v17 supports the Bulk API so it's easy to get started upload large datasets. Your user profile must have the "API Enabled" permission selected so if you are a System Administrator, you are all set. To get started, open up the Data Loader and edit the settings for the Bulk API.

Bulk settings.png

Feeling proud to get one designer exam certificaton, many more to come


Reference Links :

All the best for the exam!!

Friday, 21 July 2017

Custom Notifications with Platform Events Beta Winter'17 #Salesforce

 The platform provides an event-driven messaging architecture to enable apps to communicate inside and outside of Salesforce. Use platform events to deliver secure and scalable custom notifications within Salesforce or from external sources.

Platform Events uses event-driven (or message-driven) software architecture.
In the event driven architecture there are event consumers, event producers and channels.
Event Producers produce the event and the event are performed in real time by consumers, and the event passes through the channel. Multiple events can be produced and passed through the channel and consumed by consumers.

Here is diagram for more clearance, source Salesforce


Lets talk real now,  this Platform events can be used for sending event from salesforce or outside. For example like event of door opening and closing of a lift, and if it doesn't opens then create case.

So to handle these event in multpile ways and to process or execute these events, Salesforce has given many ways for example we can build these events using process builder and execute using flows. 
In the same way we can have apex triggers on Platform events to handle exceptions, there are few new methods have been provided by salesforce specifically for Platform Event.

Now its time for example, login to your salesforce and in quick find box, search for Platform Event
Click on new New Platform Event.

Here is one I've created 



Here I am giving an example of writing trigger and webservice on Platform Event and executing them in salesforce.

Below is the apex trigger on Platform Events, on After insert event which will check for the door open and closed value using the is_Closed__c field. if the door is closed then it will throw the exception, for exception in the Platform event, Salesforce has introduced Event.RetryableException is property to check how many times the trigger has been retried, if failed then you can perform other actions.

//Trigger on 
trigger EventTrigger on Open_Door__e ( after insert ) {

    for(Open_Door__e odEvent : Trigger.new) {
    
        //check for gate is open 
        if(odEvent.Is_Closed__c == false) {
            
            //Allowed to go in
            
        } else {
        
//exception to try event less then 4 times
            if (EventBus.TriggerContext.currentContext().retries < 4) {
            
                // Condition isn't met, so try again later.
                throw new EventBus.RetryableException( 'HOLD THE DOOR, HODORRRR.....!!');
            }
        }
    }
}



Now as we discussed the Platform events can be called or executed from outside salesforce using webservices, so here we will publish a new event using webservice, for publishing an event also we have a method called EventBus.publish().
Below we are publishing the event


global class DoorOpenAndClosedEvent {

    webService static void checkForDoors(Boolean isClosed) {

        //Check for closed door
        if(isClosed) {
        
            List<Open_Door__e> odEvent = new List<Open_Door__e>();
            odEvent.add(new Open_Door__e(Is_Closed__c=false, Working_Properly__c=true));
        
            //publish events
            List<Database.SaveResult> results = EventBus.publish(odEvent);
        
            // Inspect publishing result for each event
            for (Database.SaveResult sr : results) {
                for(Database.Error err : sr.getErrors()) {
                    System.debug('Error returned: ' +  err.getStatusCode() + ' - ' + err.getMessage());
                }
            }
        }   
    }     
}


Now execute the method in console
After running the method, go to the platform event where we have created, and down below we will see how it got published, by checking the below table, it show it give you status, published ID.


Status can be different,  Trigger states can be one of the following.



This is a small tutorial of using this newly delivered Platform Event. Soon will get to know the power of this object.

Key Points about Platform Events

  • A platform event is a special kind of Salesforce entity, similar in many ways to an sObject.
  • You cannot update or insert Platform Events.
  • event publishing is equivalent to a DML insert operation, DML limits and other Apex governor limits apply.
  • You can use any Salesforce API to create platform events, such as SOAP API, REST API, or Bulk API.

Important Links




Thanks

Friday, 14 July 2017

Get Started with Setup of SalesforceDX, using Salesforce DX CLI #sfdx

Summer ’17 contains a beta release of Salesforce DX, Salesforce DX provides you with an integrated, end-to-end lifecycle designed for high-performance agile development. And best of all, we've built it to be open and flexible so you can build together with tools you love.


So here we are going to start the setup of SalesforceDX

Step 1 : Create SalesforceDX trial org or Salesforce Dev Hub Trial Org, here is the link


         https://developer.salesforce.com/promotions/orgs/dx-signup

Step 2 : Enable the Dev hub in your org, perform below steps


Step 3 : Create a SalesforceDX user or you can use System admin user also, if your user is not a System admin, then create a permission set and assign the permission set to the salesforceDX user, permission set will have below permissions



Step 4 : Install SalesforceDX CLI

here is the link to download
After downloading the SalesforceDX CLI, install it.


After installing, it will by itself uninstall the git and re-install it again.

Step 5 : Use the sfdx-simple git repo, 

here is the link , we will get this repo in our system first, so clone it, follow below steps
Our first goal is to set up a developer project which we'll use to modify our application. It starts by cloning the repository. Use the command

             git clone https://github.com/forcedotcom/sfdx-simple.git


Then, open the directory.

             cd sfdx-simple


Step 6 : Login to SalesofrceDX

Run this command, it will install the NodeJS by itself as it requires NodeJs, and by this command we are login in to SalesforceDX org, and authorizing it.



So after this login window will open, where you need to put your salesforceDX credentials, and authorize, after that you can close the window



Step 7 : Now we will create a scratch org,


The scratch org is also created through the CLI, using a config file.
Run below command

              

              sfdx force:org:create -s -f config/project-scratch-def.json




So if you logged in the SalesforceDX org, you can see the data in Scratch org info. You are done as you've successfully created the scratch org.



Now, Push the repo metadata to scratch

      

       sfdx force:source:push



In the same way you can perform multiple actions using SalesforceDX CLI
to see more commands, enter

    

     $ sfdx force --help



Below are some commands you can use to create the metadata

To create apex class

        sfdx force:apex:class:create -n myclass


There are many things that we can do using SalesforceDX and SalesforceDX CLI, like continuos integration, source control and many more, soon will post about Salesofrce IDE 2, which can be used as of the important tool to leverage the functionality of SalesforceDX.

Here are some important links

SalesforceDX cli
SalesforceDX Developer Guide (Beta)
SalesforceDX CLI Configuration and tips
Sample Source in GitHub



thank you.