Visualforce Remote Objects

Salesforce launched Visualforce Remote Objects with Spring’14 release.

Note: This feature is currently available as developer preview.

Visualforce remote objects are proxy objects that you can use to perform DML operations on Saleforce objects and these do not counts towards API limits.

Benefits of using Remote Objects:

1. No need to use controllers or extensions.

2. Reduces the need for @RemoteAction methods in an Apex controller or extension.

3. No test classes.

Let’s go thru an example

In this example I have tried to search accounts based on their type.

1.First of all we need to define about the object we are going to use.

<apex:page>

    <apex:remoteObjects >

          <apex:remoteObjectModel name=”Account” fields=”Name” jsShorthand=”ac”>

                <apex:remoteObjectField name=”Type” jsShorthand=”ty”></apex:remoteObjectField>

        </apex:remoteObjectModel>

    </apex:remoteObjects>

Here, <apex:remoteObjects >  tag  is used to define the block were we will include everything related to Remote Objects.

This   <apex:remoteObjectModel name=”Account” fields=”Name” jsShorthand=”ac”>  is being used to  define the object on which the DML operations will be performed. Attribute name is used to hold the API name of the Object, fields attribute holds the fields you want to perform DML upon and jsShorthand is the shorthand notation for the object that you can use with the javaScript.

<apex:remoteObjectField name=”Type” jsShorthand=”ty”></apex:remoteObjectField> is being used to refer the fields if you additionally want to add some conditions in your DML operation.

Let’s go on the javaScript code

<script type=”text/javaScript”>

        function retrieveAccount(){

            clear();                     //calling clear method to clear the existing records if shown in table

            var t = document.getElementById(“srch”).value;      //getting the value from input box

            var acc = new SObjectModel.Account();                 // this defines the object on which we going to perform operations

// the below code will retrieve the 100 records from account object where Type field of the record is equal to the type defined in input box on page and will display records as part of a table.

            var acnt = acc.retrieve({where: {ty: {eq: t }},limit : 100},

                       function(err,records){

                           if(err){

                               alert(“Encountered Error”+err.message);

                           }

                           else{

                               records.forEach(

                                   function(record){

                                       var name = record.get(“Name”);

                                       var row = document.createElement(“tr”);

                                       row.appendChild(document.createTextNode(name));

                                       var table = document.getElementById(“accountTable”);

                                       table.appendChild(row);

                                }   

                               );

                           }

                        }

            );

        }

        function clear(){   // clear function to clear the existing records on page.

            document.getElementById(“accountTable”).innerHTML = “”;

        }

        </script>

Enter account type here:<input id=”srch”></input>  <!–Input box –>

    <button onclick=”retrieveAccount()”>Search</button>  <!–button which on click will javaScript method retrieveAccount –>

    <table id=”accountTable” border=”1″ cellspacing=”10″></table> <!–table that will hold records–>

</apex:page>

Now you can take a look at the functionality, this feature also works on Salesforce1 !!

Image

Unable to Download/Upload Files using Salesforce1

Hi Friends,

Recently i was playing with Salesforce1 platform.

I built a functionality where i can upload or download files from Salesforce.

Everything worked fine when i was emulating  the app behavior over the google chrome.

But i was not able to do the same on Android Device.

Investigated but not got a satisfactory answer anywhere.

Do anyone faced similar issues? Do Salesforce have some restrictions with Salesforce1 app?

Do only limited set of Visualforce Tags work for Salesforce1?

You can have a look at my post on Salesforce StackExchange over here:

http://salesforce.stackexchange.com/questions/26941/uploading-and-downloading-file-by-using-salesforce1/27253?noredirect=1#27253

Salesforce1 Development [using Google Chrome]-Part 1

6a00d83451ba7369e2019b0234ddcf970c-320wi

In Dreamforce’13 Salesforce1 was announced , a new mobile app for Salesforce platform,that makes the platform easier to use.

Available for :

1.iOS 6+

2.Android 4.2+

We can do development with Salesforce1 right from the Google Chrome browser on our Desktop.

First of all we need to make sure that the user have rights to access the salesforce1 .

In-order to make the user capable to access salesforce1 we need to grant access to that user , that we can do by Manage Users>Users>Edit [in front of that user]>check the check box “Salesforce1 User”.

UntitledSecond thing to do is to allow the salesforce1 to run as the mobile browser app right from our desktop web browser , to do this go to  Mobile Administration>Salesforce1

UntitledThen check the check box “Enable the Saleforce1 mobile browser app”

UntitledNow by doing so we can simply access the mobile app right from our desktop [by using google chrome only]

To do that simply prefix /one/one.app after your salesforce instance in the address bar of  our google chrome browser.

For example my instance is https://ap1.salesforce.com

So the URL to access the salesforce platform becomes like this :

https://ap1.salesforce.com/one/one.app

When we go on this URL we get following screen with a cool salesforce logo

Untitled

Home page is like this :

UntitledNow if we need to test this app according to the end user device and configuration we can do it by pressing F12 or right-click to Inspect Element.

UntitledNow we can see the inspect element section [Developer Tools]

UntitledNow click on the Elemens Tab and then the Gear Icon [as highlighted in the above image by red squares].

Now settings will open up where we need to select Overrides , here we can change the user agent and simulate the behavior  of this app on the respective device.

Untitled

Visualforce Developer’s Guide: A book review.

If you are looking for a guide to learn visualforce then a new guide has arrived, that is well organized for both newbies and advance developers. Thanks to @chamilmadusanka for putting all his hardwork in this book.

9818EN_Cover

I got a chance to review this book(Thanks to Packt Publishing and Sagar Malage ) and here are my thoughts :

1.This book is having 8 chapters with step by step things to follow ,it covers basics in the first chapter to advance level in the final chapter.

2.Key point of this book is best practices  and security tips for the visualforce are also included.

3.Steps are detailed and easy to follow, you hardly miss anything that visualforce have.

Following are the chapter wise things i liked and which i think that makes this book different

1.Chapter One: Advantages of visualforce.

2.Chapter Two:  Working with large sets of data on visualforce page.

                          Using Transient Keyword

                         Considerations for creating custom controllers and controller extensions ( That is         again as i said is part of best practices).

3.Chapter Three: I liked the way javascript and jQuery  explained in this chapter.

4.Chapter Four: Good  brief description about custom components

5.Chapter Five: Detailed discussion about dynamic binding .

6.Chapter Six: Visualforce Charting: This a must read chapter if you have never touched the charting part of visualforce best effort are made by author to explain . I also got good knowledge from this chapter.

7.Chapter Seven : Going Mobile with visualforce? Take look at this chapter, nicely written and explained .I recommend developers who are looking to learn the mobile part of visualforce to start with this book .

8.Chapter Eight: It includes best practices part, that most books miss.

I loved the way this book ends with Security tips.

Why to go for this book?

1.Easy and quick to understand.

2.Hands-on Approach

3.Basic development to Mobile Development Included.

4.Security and Best Practices Included.

You can buy this book from here : http://bit.ly/Ii5X6p

Chatter Actions

Recently i had a requirement with salesforce’s new feature Chatter Publisher Actions. I struggled to understand what it is and how it works and finally learned it ! So making it easier for all others like me here comes my post to understand this new feature. And as Mark Benioff already announced that chatter will become primary interface for salesforce. I believe its necessary to post about it.

So it was a big paragraph? Let come directly on the point !

Chatter Actions

A new feature which allows us to create actions and they can be added on:

1.Chatter Publisher on Home Page.

2.The Chatter Tab.

3.Record Detail Pages.

Type of Actions

1.Create Actions  : you can create a record on target object.

2.Custom Actions : let you define your own custom action. (Note that these are visualforce pages).

We can create actions that let user create these types of records:

Account, Campaign, Case, Contract, Contact, Custom Objects, Event (without invitees), Lead, Opportunity and Task.

These Actions can be specifically categorized as

1.Object Specific. (Supported Objects: Account, Campaign, Case, Contract, Custom Objects, Lead and Opportunity.) Remember the visualforce page you are going to bind it with Object specific action must have its standard controller of that object.

2.Global Actions: lets you create actions that are available globally .

Enable Chatter Actions:

Under Chatter>Settings>Publisher Actions>Enable Publisher Actions.

1 step

Now lets take an example:

Suppose you want to add a contact record to an account record by using object specific actions

In this case your object specific action will be defined on Account.

So go under Customize>Accounts>Buttons, Links and Actions

2 step

on the next screen click on New Action

You have to define action like this :

step3

Click Save

Now comes the last part Adding this Action to Page Layout

Customize>Accounts>Page Layouts 

edit Account Layout

Now you can see a additional Option as Actions

4 step

Now before dragging Add Contact Action to layout don’t forget to click on “override the global layout“.

The reason behind this is you are setting a customized list of actions for this layout and no more need the default functionality anymore.

5 step

Now drag your action

55step

Now save this layout.

Now if there is feed enabled for accounts you will be able to see your created action like this

axtion

NOTE :If you want to  use a custom action make sure you have a visualforce page that is having a standard controller for that object.At the time of defining the custom action you will see only those visualforce pages who have  standard controller for that object for which you are defining the custom action.

Thank you for reading this post.

Workshop in my college.

As part of amazing journey with salesforce,this was another great experience that i had this month. I  got some job offers ( I was on the first rank in each recruitment)  and college faculty was asking to teach some things that i had learned of my own  and share them with my juniors. Plus i got some requests from colleges from Jaipur to organize workshop in their college on salesforce. As college annual function and technical event was approaching

I was asked to co-ordinate workshops.

So i decided to organise following workshops in my college:

1. Salesforce Platform Workshop (With force.com workbook exercises). 

2.A cyber security workshop( to share some tips and tricks they call it “Hacking” and i won’t).

3.A website designing workshop for the juniors to make some cool websites  on php.

From the above the three highest strength was in first one and about 150 students were there. Believe it or not, labs were going to be full , so decision was take to broke down it into 3 days workshop. Finally as i was sure those 3 days were exciting. Beginning from 2nd March to 4th March ,everyone there experienced those things they never thought off ! .Gave them about 2 hours of declarative side hands on time and distributed the workbooks and cheatsheets for the home-work task ;) Followed up by a Q/A session on 7 and 8th March based on workbook exercises.

Starting up from the intro to the platform to the deep diving i included everything that i can explain them .Thanks to Mr.Rakesh Kumar as he was there to take the remote session via google hangout.

 ABCD00164
 vert
 MIT
row
IMG_20130318_150437
sem
The following was the outcome of the workshop :
1.A group of students (70) agreed to join the user group, they will attend meetings.
2.My story set an inspiration to all and was highly appreciated.
3.I found 60% students actually want to work on this platform.
I hope now they will do their summer training on this platform :) and that will add into their career.
I would like to thank:

Kavindra Patel (@kavindrapatel)

April Kyle Nassi (@thisisnotapril)

Rakesh Kumar (@rakeshistom)

 

About Me

I am Sagar Pareek

Force.com Certified Developer

Developer User Group Leader  India Students  Developer User Group

and Co-Leader Navi Mumbai Developer User Group

Currently working at Astrea IT Services Pvt.Ltd. NOIDA (India)

My hometown is Bikaner,Rajasthan (India).

Author of : Developing Applications with Salesforce Chatter , Packt Publishing.

Follow

Get every new post delivered to your Inbox.