Tuesday, July 16, 2013

Sorting Columns With Null Values In SOQL

Recently one of my friend was faced a problem. He wants contact list in sorted order, but the issue is he wants sorting the table according to email columns where some records are without email value.
In that case sorting result is like this type
he fired this Query -
select id, lastname, email from contact order by email 

When he tried to sort in descending order then result is -
he fired this Query -
select id, lastname, email from contact order by email DESC

In a descending case result was wrong. Result must be show where null email values are at the last.
Sorting are working on filled values not on Null value.
So,
I found the way of sorting values including null values. -

select id, lastname, email from contact order by email DESC NULLS LAST

Using this query you will get this type of result - 

NULLS LAST is a keyword for including the null values in a order column. 




Thursday, July 11, 2013

Google Map on a Field

We have seen lots of code for google map implementation. But, all codes are for Visualforce pages. Users created a visualforce page and classes for implement google map. But,

Today I introduce you how you implementation of  google map on a Field.

For This, you will need to create a Custom Label with these values -
Name :               GApiKey
Short Description : GApiKey
Value  :                      BbiTjwR8z1eBST0mNpJvtWvmgvEdrgGXs5szHHahQdD86Zd50nyAzG0QAkxwmgieQrLQ


Then create a Formula field ( type - text) with this formula value - 

IMAGE(
"http://maps.google.com/maps/api/staticmap?center=" + BillingStreet + "," + BillingCity + "," + BillingState + " " + BillingPostalCode +"&zoom=13&size=650x250&markers=color:blue|" + BillingStreet + "," + BillingCity + "," + BillingState + " " + BillingPostalCode + "&sensor=false&format=png32&key=" + $Label.GApiKey
, "no map available", 250, 650)

After adding this field in a object page payout, Result will shows like -


I created a Location name formula field for demo to show Google Map on Field. 
Here the link for online demo: