Spring 09 Release - A Whole New Force.com or Just a Few New Goodies?

After attending the Spring 09 Release the other day in hope of seeing at least some of the good ideas making way to force.com platform, features such as inline editing for Visualforce pages, more flexibility with custom of related-lists, flexibility on using the advanced Apex features to create customized reports and dashboards, etc following observations were concluded:

Well not all of them made it! in fact, we can summarized the release merely around some enhancements here and there in the platform.

Some of you would even think that in this economic downturn, one can not expect more than this from IT companies. Should this thought ever cross our minds, I would not rule this factor out as an impact on this release!

Let's have a look and quickly browse through the enhancements of the Spring 09 release:

  1. Force.com Sites Improvements

    • Audit Trail:
      Now you can track all the changes made to your sites by different users.

    • Sites Robot.txt and Fav Icon:
      With this release you will be able to set a robot.txt for you force.com site which enables you to better control how search engines should index your site's pages. Fav Icon is also a useful way of personalizing the browser in showing an icon next to the title of your website (in tabs) and also in favorites/bookmarks.

    • Standard Pages:
      Allows you to bring selected standard pages and expose them to the public via your force.com site (suitable for ideas page, etc).

    • Sites Packaging:
      With this feature we can package force.com sites, apex code, etc and install them into other instances.

  2. Force.com Web Service API Improvements

    • Improvements in the timeout limits of the callouts:
      This is potentially good when the code takes a longer time to process and bring back the results. Now we can configure it in a way to have extended timeout periods resulting in more run-time stability.

    • Also Wider range of WSDL types are supported by Spring 09 release.

  3. Database and Reporting

    • Summary Report Data Snapshots:
      Previously data snapshots were available on reports, however, with this release you can use snapshots across large amounts of data, where only the summaries will be stored, as well as create historical views of metrics, KPIs and other summary data.

    • Data Grouping Functions:
      This is actually a very useful upgrade, now you can group the entries of a report to better analyze aggregate data.

    • Delegated Data Administration:
      This feature allows you to grant permission to non-admin users to report, search, modify, transfer, share, unlock, or approve any record regardless of sharing settings on an object basis.

    • Dashboard Finder:
      This enhancement allows you to search through your dashboard items (a real time-saver!).

  4. Force.com IDE

    • Apex Code Auto-Complete in Force.com IDE:
      Finally! When you are coding in Eclipse (force.com IDE) auto-complete feature will be available to assist you with writing the code.

  5. User Interface

    • Enhanced Page Layout Editor:
      This one is my favorite enhancement, using this feature now you can create much better layouts. You can drag and drop fields and items around, "save as" a layout, leave a spot empty (blank spaces), design the mini-layout, etc.

  6. Services

    • Cross-Object Workflow:
      With this feature you can update a field on a parent record within a workflow!

    • Access to Email Logs in the Application:
      This report shows you whether your outbound emails were received or bounced back and basically gives you a comprehensive log of your outbound emails.


  7. Force.com Logic


  8. Mobile

    • Mobile Web Tabs for iPhone
      You can now create mobile-ready Visualforce Tabs for the iPhone. This enhances the client with a near-limitless method of extension - enabling you create content for the iPhone using the Visualforce user interface framework. The hybrid iPhone client that supports this functionality will be released next month.

Allow Mass Update of your Object Records Even Without Having a Save Button!

Today we want to explore one of the beauties of the Visualforce technology.
Those who have a history of witting ASP or ASP.NET code will admit that Visualforce has made it all too simple to develop business applications.

Let's say we want to be able to update several records of a certain Object all together providing ability for users to quickly make modifications and save them.

This is particularly useful when the data in nature changes often and it's time consuming to do the updates on a record by record basis.

In this example, I will demonstrate a Visualforce page which has a search box through which user can search Accounts and view a list of records where he or she can modify the information inline and then proceed to the next record without clicking on a save button of some sort!

This is very much as easy of entering data into cells of an excel sheet! The only difference is that the Excel needs you to click on the save button at the end but our Visualforce page won't!

I will use an actionFunction tag to create a javascript function which in turn will trigger a method of my Apex controller class. This way when the value of one the input controls changed I can call that javascript function and boom the change would get posted back to the controller and will be saved.

This the how Visualforce page is like:

<apex:page tabStyle="Account" controller="massAccountUpdateCon">
<apex:sectionHeader title="Accounts Mass Update"></apex:sectionHeader>
<apex:form >
<apex:pageBlock title="" id="pageBlock">
<!-- This block will show the search textbox and the Search button -->
<apex:pageBlockButtons location="top">
<apex:inputText value="{!keywords}" style="height:15px;"></apex:inputText>
<apex:commandButton value="Search" action="{!ViewData}" id="theButton" rerender="pageBlock" status="status"></apex:commandButton>
</apex:pageBlockButtons>
<!-- To show page level messages -->
<apex:pageMessages ></apex:pageMessages>

<!-- The below tag will provide a javascript method which when is called in turn will call a controller's method -->
<apex:actionFunction action="{!UpdateRecords}" name="updateRecords" rerender="pageBlock" status="status"></apex:actionFunction>

<!-- This table contains columns which have inputfield components -->
<apex:pageBlockTable value="{!accounts}" var="a" rendered="{!NOT(ISNULL(accounts))}">
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:inputField value="{!a.Name}" onchange="updateRecords();"></apex:inputField>
</apex:column>
<apex:column >
<apex:facet name="header">Phone</apex:facet>
<apex:inputField value="{!a.Phone}" onchange="updateRecords();"></apex:inputField>
</apex:column>
<apex:column>
<apex:facet name="header">Billing City</apex:facet>
<apex:inputField value="{!a.BillingCity}" onchange="updateRecords();"></apex:inputField>
</apex:column>
<apex:column>
<apex:facet name="header">Billing Country</apex:facet>
<apex:inputField value="{!a.BillingCountry}" onchange="updateRecords();"></apex:inputField>
</apex:column>
<apex:column>
<apex:facet name="header">Industry</apex:facet>
<apex:inputField value="{!a.Industry}" onchange="updateRecords();"></apex:inputField>
</apex:column>
</apex:pageBlockTable>

</apex:pageBlock>

<!-- The action status to show when the AJAX postback is wroking. -->
<apex:actionStatus id="status" startText="Requesting..."/>
</apex:form>
</apex:page>





Now the Controller, this is where the simplicity of coding can be visibly seen!
As you can see in the Controller's source code, I do not need to write any code to find which column's value was changed! All I need to do is to update my List of Accounts!
Visualforce will take care of all those details!


public class massAccountUpdateCon {

private List<Account> accounts;

public List<Account> getAccounts() {
return accounts;
}

public string keywords {
get;
set;
}

public PageReference ViewData() {
//dynamically build the query to insertthe filter values
String query = 'Select id, name, type, ownership, industry, phone, BillingCity, billingCountry FROM account WHERE name LIKE \'' + keywords + '%\'';

accounts = Database.query(query);

return null;
}

public PageReference UpdateRecords() {
// this simple line of code finds out which column was changed and update the
// relevant account record accordingly!
update accounts;
return null;
}
}




Visualforce Component to show Object Record Types

Happy New Year!

Time definitely flies and I wish you wonderful times in 2009!


Part of our daily job is to make life easier for others by developing new applications in force.com platform. But sometimes it's not bad to spend some time for ourselves to make our own life a little easier, better and smoother.

In this article I will present a Visualforce Component that would list the record types of an Object in the platform.

Imagine, the Account object has two record types in the force.com platform (Record Types are created by the users based on what these objects represent on their business).

Account Record types:
  • Customer
  • Partner
In many occasions especially when developing a new wizard you need to first allow the user select what type of record they want to create and then based on that show the correct type of interface to the user.

The solution as to how you can show this to the user is rather simple, but here I actually took the time to create a re-usable component, so you and I won't need to rewrite the code next time!

Here is the Component's Tags:


<apex:component controller="RecordTypeListCon">
<apex:attribute name="sObjectType" description="" type="String" required="true" default="Account" assignTo="{!sObjectType}"></apex:attribute>
<apex:attribute name="value" description="" type="String" required="true"></apex:attribute>
<apex:selectList value="{!value}" size="1">
<apex:selectOptions value="{!items}"></apex:selectOptions>
</apex:selectList>
</apex:component>



The Component has a Controller called "RecordTypeListCon" and is named as "RecordTypeList". It declares two attributes as follow:

  • sObjectType: values such as "Account", "Contact", generally the name of your object.
  • value: you can capture the result of user's selection by using the attribute in your Vsualforce Controller.

And here goes the code of the component's Controller:


public class RecordTypeListCon {
private List<SelectOption> items;

// property that reads the value from the Component attribute
public string sObjectType
{
get;
set;
}

public List<SelectOption> getItems() {
List<SelectOption> items = new List<SelectOption>();

//default value
items.add(new SelectOption('','--Select Record Type --'));

//query force.com database to get the record type of the requested object.
for(RecordType rt: [select id,name from recordtype where sobjecttype=:sObjectType]) {
items.add(new SelectOption(rt.id,rt.name));
}

return items;
}
}




Once you create this component in your Salesforce instance all you need to do when need to the selectList of your object's record types is to:


<c:RecordTypeList value="{!lookupValue}" sObjectType="Account"></c:RecordTypeList>




Enjoy!