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.

Thursday, 13 July 2017

Using ui:collapse in Lightning Component #Salesforce


Here I am going to use ui:collapse, if you trying to add a functionality of hover or Accordion this can be a big help, here we are using ui:collapse , ui:menu, ui:menutriggerLink in which we have some child functions also, You can handle this event in a ui:menuList component instance. This example shows a menu component with two list items. It handles the ui:collapse and ui:expand events.
So here it is, you will have one or two link like below, on the click of which user will have a hover where by ui:actionmenuitem we can call other functions.


And using ui:collapse and other tags, we can achieve this



To achieve the above look and feel and the functionality

Here is the component code of the lightning component,

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    
    <aura:registerEvent name="menuCollapse"  type="ui:collapse" description="The event fired when the menu list collapses." />
    
    <html>
        <body>
            <div class="accordion">
                <ui:menu>
                    <ui:menuTriggerLink aura:id="trigger" label="Contacts"/>
                    <ui:menuList class="actionMenu" aura:id="actionMenu" menuCollapse="{!c.addMyClass}" menuExpand="{!c.removeMyClass}">
                        <div class="accordion">
                            <p>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                            <ui:actionMenuItem aura:id="item1" label="Go to Contacts" click="{!c.doSomething}"/>
                        </div>
                    </ui:menuList>
                </ui:menu>
            </div>
            
            <div class="accordion">
                <ui:menu>
                    <ui:menuTriggerLink aura:id="trigger" label="Acounts"/>
                    <ui:menuList class="actionMenu" aura:id="actionMenu" menuCollapse="{!c.addMyClass}" menuExpand="{!c.removeMyClass}">
                        <div class="accordion">
                            <p>aliquip ex ea commodo consequat.</p>
                            <ui:actionMenuItem aura:id="item1" label="Go to Accounts" click="{!c.doSomething}"/>
                        </div>
                    </ui:menuList>
                </ui:menu>
            </div>
        </body>
        
    </html>
</aura:component>


Here is the controller

({
  
    addMyClass : function(component, event, helper) {
        var trigger = component.find("trigger");
        $A.util.addClass(trigger, "myClass");
    },
    removeMyClass : function(component, event, helper) {
        var trigger = component.find("trigger");
        $A.util.removeClass(trigger, "myClass");
    }

})


Here is css code

.THIS .accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
}

.THIS .accordion:hover {
    background-color: #ddd; 
}

Now to test, create one sample app and preview it.


Hope it helps, feel free ask any queries.
Thank you!

Friday, 2 June 2017

Configure Properties in Lightning Component #Salesforce

Hi All, this blog post is about using lightning properties, this one of the great feature of the lightning component where you can see how dynamic you can make your lightning component, I am just showing a sample usage, I am pretty sure that we can use it in much more effective way.

Currently we have only few types of properties in lightning component i.e. Text, Integer and Boolean.
You can manipulate it and use it in more better way.

Here is it how it looks and how you can use it,

Note : Properties will be only visible when you define it in the Lightning component, and you can use the properties after adding it on the detail page / home page in lightning experience.

This is how it looks when you define properties in lightning component.



To define property in Salesforce you need to define Design:attribute in your design resource of lightning component.

For example below is our  lightning component having properties defined.
To appear in the Lightning App Builder or on a Lightning page, a component must implement the flexipage:availableForAllPageTypes interface.



<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickAction,force:hasRecordId" access="global" >
 
    <aura:attribute name="check" type="boolean" access="global"/>
    <aura:attribute name="Name" type="String" access="global"/>
    <aura:attribute name="Number" type="Integer" access="global"/>
    <aura:attribute name="Picklist" type="String" access="global"/>
    
    "{!v.check}" toggle on check, like below
    <BR/>
    <aura:if isTrue="{!v.check}">
     <!-- toggle content -->
    </aura:if>
    
    "{!v.Name}" Show or Hide on the basis of user input
    
    <BR/>
    
    "{!v.Number}" only integer 1,22,333 allowed
    <BR/>
    
    "{!v.Picklist}" User can chose in between few options.
    
</aura:component>


And here is the code of design resource, we have defined 4 different types of properties here.


<design:component >
 
    <!-- properties -->
    <design:attribute name="check" label="Check" />
    <design:attribute name="Name" label="Label" />
    <design:attribute name="Number" label="Number" description="Only numbers." />
    <design:attribute name="Picklist" label="Pick One" datasource="Yes,No, May be" default="Yes" description="Please select one"/>
    
</design:component>

No go ahead, add you you lightning component in a detail page of any object in lightning experience, and then set the properties values.

I've tried to create more type of property but can't as the error itself show while you try to create a new type of property. You'll get something like below




How to remove a Property !

That is a little tricky part while adding your property its easy add an attribute in component and then in design done. But while removing it, you need to use these below steps to remove it from the lightning component

1. Remove Implements from the lightning component source.
2. Then remove Design attribute from the design resource.
3. Now remove the attribute in the component. click save.

Done.

Hope this helps!!
thanks

Friday, 19 May 2017

Expanding the features of Lightning Component Using Visualforce page #Salesforce - Part 2


Previously we have used the Lightning component inside visualforce page, now this we are going to use the visualforce inside lightning page, and set some attributes default value on load of the lightning component using visualforce page, here what we are going to achieve is that we will load the visualforce page, and then remaining process of Lightning component order or execution will be same.



So here we are going to have a visualforce page, that will save/update the data in the custom setting, and the out lightning component will use the same data in custom setting.

So here is the visualforce page, that we are going to use in lightning component, and this page is updating the your custom setting.

Page Name : UpdateCustomSetting


<!-- defining custom setting here -->
<apex:remoteObjects jsNamespace="RemoteObjectModel">  
    <apex:remoteObjectModel name="MyCustomSetting__c" fields="Id,Field1__c,Field2__c">  
    </apex:remoteObjectModel>  
</apex:remoteObjects> 

<script>
//to save data in custom setting 
function updateCustomSetting() { 
    
    (new RemoteObjectModel.MyCustomSetting__c()).retrieve( 
        function(error, records, event) {
            if(records[0]) {
                (new RemoteObjectModel.MyCustomSetting__c({
                    Field1__c: '{!$Api.Partner_Server_URL_XXX}', 
                    Field2__c: '{!$Api.Session_Id}',
                    Id: records[0].get("Id")
                })).update();
            } else {
                (new RemoteObjectModel.MyCustomSetting__c({
                    Field1__c: '{!$Api.Partner_Server_URL_XXX}', 
                    Field2__c: '{!$Api.Session_Id}'
                })).create();
            }
        });
}

updateCustomSetting();
}
</script>


The way of using the visualforce page in the lightning component, is by calling the visualforce page using iframe.


<aura:component implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
     
    <div style="display:none;">
        <iframe aura:id="vfFrame" src="{!'https:// + YOUR_ORG_URL + dev-ed.my.salesforce.com/apex/UpdateCustomSetting'}"/>
    </div>

    //YOUR COMPONENT CODE HERE


    //assign the value to these in the helper by calling apex 
    <aura:attribute name="FIELD1" type="String" access="public"/>
    <aura:attribute name="FIELD2" type="String" access="public"/>

    Custom Setting value :: "{!v.FIELD1}"
    

</aura:component>
    


Using above code you will be able to use the custom setting field values in your Lightning component.

Hope it helps !

Thursday, 11 May 2017

Expanding the feature of Lightning Component Using Visualforce page #Salesforce - Part 1

This blog post is all about using the lightning component with some extra feature that stand alone lightning feature doesn't provide some time.
Recently I was working on few Lightning component, and ran into a issue of requirements where
lightning component doesn't supports due to security issues or whatever.

For example
If you want to perform AJAX call using lighting component, you cannot bummer! here is link for reference Link

Another problem is that when you are using the Session Id on visualforce page, that session Id is different then what lightning component has. Bummer again ! So sometimes what happens if the third party is configured with your visualforce page sesion Id using "{!API.SessionId}" then your session Id generated in lightning component will no more support it.

Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .visual.force.com or .lightning.force.com.

So to resolve all this or another way to achieve these functionalities, you can you use Lightning component inside your visualforce page.

I am going to refer my component that I've posted earlier click here and use that same component inside visualforce pages, I am using sessionId and other thing in viualforce page and right away we can use those in attributes in lightning component as well.

<apex:page standardController="Account">
    <apex:includeLightning />

    <div id="lightning" />

    <script>
        $Lightning.use("c:TestApp", function() {
          $Lightning.createComponent("c:RecordTypeSelector",
          { 
              sessionId : "{!$API.Session_ID}",
              partnerURL : "{!$Api.Partner_Server_URL__xxx}",
              recordId : "{!Account}" 
              
          },
                                     
          "lightning",
          function(cmp) {
            // do some stuff
          });
        });
    </script>
</apex:page>


Now you can use these below attribute inside the component


<aura:attribute name="recordId" type="String" access="public"/>
 <aura:attribute name="sessionId" type="String" access="public"/>
    <aura:attribute name="partnerId" type="String" access="public"/>
   


NOTE : If you are using you lightning component on some object detail page, then force:hasRecordId will stop working after using lightning component inside visaulforce page, so you need to remove it from "implements" tag, that is why I've passed the object Id as well.

Here are some links for referece

Visualforce Developer Guide
Lightning Components in Visualforce with Lightning Out
Use Lightning Component in Visualforcery Jitendra Zaa
Use Lightning Components in Visualforce Pages


Hope this helps !!