Tuesday, October 29, 2013

Looping Map in Apex Salesforce

How to loop map?Use values().It is quite useful if the map contain object where we need to get the object property.



Map<String,String> mapStr = new Map<String,String>();

mapStr.put('A','angsa');
mapStr.put('B','beruk');
mapStr.put('C','cicak');
system.debug('@mapStr ======'+mapStr);
for(String s:mapStr.values()){
    system.debug('@'+ s);
}
The output :
DEBUG|@mapStr ======{A=angsa, B=beruk, C=cicak}
DEBUG|@angsa
DEBUG|@beruk
DEBUG|@cicak

Thursday, October 03, 2013

Escape from Single Quote

Everytime I need to do soql statement I have to googling around.I keep forgeting.

Okay, I copy this from salesforce link here.
SequenceMeaning
\n or \NNew line
\r or \RCarriage return
\t or \TTab
\b or \BBell
\f or \FForm feed
\"One double-quote character
\'One single-quote character
\\Backslash
LIKE expression only: \_Matches a single underscore character ( _ )
LIKE expression only:\%Matches a single percent sign character ( % )


This is how I run query using escape for single in Force Explorer.
select Id,Name from Country where Name in('COTE D\'IVOIRE','CURACAO','KAZAKHSTAN',
'LAO PEOPLE\'S DEMOCRATIC REPUBLIC','LIBYAN ARAB JAMAHIRIYA','MACAO')
order by Name
Done.:)