Saturday, February 20, 2016

[Salesforce / Trailhead] Presenting the "Navigate the Salesforce Advantage" trail aka What is Salesforce?

This is a technical blog ("Nerd @ work" say it all) and I usually post exclusively technical stuff.

But in the recent trailhead additions there is a special set of modules that basically answer the question "What is Salesforce and what's the reason of its Success?"

This is the Navigate the Salesforce Advantage trail and it is meant for those who don't know anything about the platform and for those who want to better understand the reason of the success.

I may say that if I could have read these modules when I first started making the first steps in the Salesforce platform, I would have understood in few minutes why Salesforce is that awesome...but you know, I discovered it by coding and coding and coding...

What I say before presenting the trail,

Here is a walkthrough of the key concepts of the trail.

Salesforce Success Model

Are you new to Salesforce? Not sure exactly what it is or how to use it? Don’t understand what makes Salesforce special? If you’ve answered “yes” to any of these questions, then you’re in the right place. No matter what brought you, we’re glad you’re here.

Salesforce is a platform of connected features that helps you to make your customers love you (I mean not actually you, but your company!)

How do Salesforce do it? It's success is handled by the following 4 rules:

  • Customer success: "why can’t buying enterprise software be as easy as buying a book on How can we make it easier for customers everywhere to achieve their goals?"
  • Leadership: "Cloud is still the medium for everything we do. This means all our focus is on innovating the best apps and platform technologies for our customers. This is what we do, all day, everyday."
  • Innovation: "Our customers drive us to be more innovative. ... Because what they can do with Salesforce is truly amazing."
  • Giving Back: Our 1-1-1 Model: "To us, the business of business is not business. The business of business is to improve the state of the world."

Salesforce Cloud Benefits

"To answer to what Salesforce is and what it does truly depends on each customers’ definition of success. ... So it’s up to us to be their Swiss Army knife and provide them with a neatly packaged range of tools to choose from. ... The aim is for our customers to have the right mix of tools at the right time."

All the platform features help your customers to solve several issues in their business thus increasing their business with super powers:

"There’s a Salesforce App Cloud for That".

And yes, it is all in cloud, Software As A Service (SAAS)!

"It means that we maintain the infrastructure and do all the heavy lifting so you can focus on what matters most to your business."

Salesforce Technology Basics

Understand the basics of the platform.

Security: "At Salesforce, trust is our #1 priority. Data is one of the most valuable assets that each one of our customers possesses."

Multitenancy: "every customer shares the same infrastructure and runs on the same platform. It’s that simple"

Metadata driven architecture: "When we talk about metadata at Salesforce, we’re talking about our metadata-driven architecture that allows each customer to customize their own instance of Salesforce. ... Salesforce separates our customers’ customizations into a special metadata layer, so we can update and improve our platform in the background without touching any of their data or customizations"

Fast app development: "Building an app with Salesforce is different. There is no installation of hardware and software, and there are standard options for defining security and user access, creating reports, and making the app social and mobile. Metadata allows us to have all of this pre-built in a separate layer for our customers, so all they have to do is add any customizations they may want as icing on the cake. ... Point-and-Click Configuration for all, Custom Code for developers"

Salesfoce Ecosystem

"Our ecosystem was created to help customers get access to whatever they need, whenever they need it."

It's the power of the Community that makes the platform so powerfull.

How to keep in touch with all of us?

  • Dreamforce: this is a HUGE event where you'll meet people from all over the world
  • Attend a local event: join a local User Group or Developer Group
  • Explore the AppExchange
  • Consult with an Implementation Partner

How huge the Community is?

"We developed the online Salesforce Success Community as a place where business users, admins, partners, and employees can go to find answers, get synced up with their local user groups, help new customers get started, and get active in a community of enthusiastic and innovative people."

Meet Our MVPs
I'm one of them now, you can catch me and ask wathever you want, we are here to help!

"The most incredible thing about our MVPs? Not a single one is an employee. They put in all this time and effort for the good of the Salesforce community, and we recognize them for their leadership, knowledge, and ongoing contributions. These individuals represent the spirit of the community and what it is all about!"

Thursday, February 18, 2016

[Salesforce / MVP] Yes guys, I'm a Salesforce MVP! And Thank you all!

Today I woke up and... BAAAMM!

I've been nominated a Salesforce MVP: read the announcement from the Salesforce MVP blog.

This is an honor and a motivation of pride for my carreer, and I know I have to thank the whole Community for this awesome achievement!

This post is just to say thank you all!

In the next days I'll publish a new post to describe my trailhead to the MVP!

The next question is: am I the first Italian Salesforce MVP?

Update 2016-02-29

Yes I am!!

See you in the next posts!

Tuesday, February 9, 2016

[Salesforce / Visualforce] Handling Viewstate with Dynamic Visualforce components

I've written this post thanks to the help of my colleague Ivano Guerini who has found the solution to the problem I'm going to expose and written down the code you'll see in this post.

This post is about correctly handling the viewstate when dealing with Dynamic Visualforce Components.

For those of you that have never worked with dynamic components, they are a way to create visualforce components using Apex.

For example the following piece of code returns a Page Block Section with 2 input fields on the Account record:

public Account record{get;set;}

public ApexPages.Component getDynamicComponent() {
    Component.Apex.PageBlockSection result = new Component.Apex.PageBlockSection();
    result.columns = 1;
    List sectionItems = new List();

    Component.Apex.InputField input = new Component.Apex.InputField();
    input.expressions.value = '{!record.Name}';

    input = new Component.Apex.InputField();
    input.expressions.value = '{!record.Website}';

The visualforce should be called as follows:

    <apex:dynamicComponent componentValue="{!dynamicComponent}" />

The page prints out a page block with a page block section with 2 input fields for the Name and Website Account's fields.

The following code has been packed up in this Github repository for further testing and improvements.

If you wanna know more about viewstate this article is a good starting point.

Generally speaking, the viewstate is an input hidden field inside your Visualforce forms that contains all page data and that is used to post your form back to the server and forth to the page.

Too many informations, are you still there?

The problem comes when you try to use dynamic components (that can vary between post backs) and the Visualforce block your post back because of (for instance) required fields: in this specific case the dynamic components does not maintain the viewstate because the postback is blocked just before arriving on the server, so the components are created again and their status is lost.

You can test this behavior by calling the /apex/DynamicViewStateExample?id=[ACCOUNT_ID]&skip=1 (the skip parameters calls the page without the fix shown at the end of this post):

To fix this problem we need to replicate the viewstate component to re-apply the values to the different input fields after the postback has been done.

In your page we have added an apex:inputHidden component called viewstate:

<apex:dynamicComponent componentValue="{!DynamicComponent}" invokeAfterAction="true" />
 <apex:inputHidden value="{!viewState}" id="viewState" />

The trick is to use Javascript to serialize/deserialize the view states.

We use the Serialize jQuery plugin to serialize form data but we had to write our own deserialize method (see the jQuery_Deserialize static resource for more details).

This part of the code is called when there is a post back:

var closestForm = jQuery('[id$="{!$Component.viewState}"]').closest("form");
    closestForm.on("submit", function(event) {
        //serialize esch component except the "viewState" component to avoid recursion

And this part is the code that actually deserializes the "custom" viewstate and put it in the form fields:

if(closestForm.find('[id$=viewState]').val()) {

This few lines of Javascript actually to the magic!

For more details on the implementation, have a look at the DynamicViewStateExmaple page and the DynamicViewStateCmp component.