Skip to main content

Posts

Showing posts from 2013

Delivering package for you HO HO HO

I got package for you!! Whenever I want to retrieve the code from Salesforce I seldom use Force IDE UI.I mean the one that we need to right click at Force.com -> Add/Remove Metadata Components . It slow and for unknown reason sometimes it hang my system. Other work around that I use is directly write the class,trigger or anything that I want in package file and then click Force.com ->Refresh from Server . So here the sample of package file <package xmlns= "http://soap.sforce.com/2006/04/metadata" > <types> <members> MyApexClass </members> <name> ApexClass </name> </types> <types> <members> MyApexTrigger </members> <name> ApexTrigger </name> </types> <types> <members> MyCustomApplication </members> <name> CustomApplication </name> </types> <types> <

Action function causing Object doesn't support this property or method in IE8

Anyone love IE? Ha ha ha... I don't like it because IE love to catch my code...uppss :) I have this web application that fusion of Salesforce and JQuery.It quite happy to run in Chrome and Firefox but not in Internet Explorer.It give this: Message: Object doesn't support this property or method Line: 1934 Char: 1 Code: 0 I spend the whole day staring at my screen.The code is doing rating by change the  color  and save to database .It run in another two browsers but somehow it show error in IE bar.There two code snippets that run with same function however the first one is not hitting the error, but the second one yes.  First code <apex:outputpanel id= "Price" > <div id = "Price1" class= "{!IF(Rating['Price Detail'].Rating_Color__c=='Yellow','light light-yellow', IF(Rating['Price Detail'].Rating_Color__c=='Red','light light-red', IF(Rating['Price Detail'].Rating_

Run Execute Anonymous in Java Script for Custom List View Button

The application is required to run in schedule.I have Schedule class and Batch class.I call Batch class inside Scheduler like this global class MySchedulerClass implements Schedulable { global void execute ( SchedulableContext sc ) { MyBatchClass c = new MyBatchClass (); Database . executeBatch ( c , 5 ); } } But during development, I didn't schedule the job.I directly run in Apex Execute Anonymous like this: MyBatchClass c = new MyBatchClass (); Database . executeBatch ( c , 5 ); So I can see the result quicker instead of waiting the job to be run on specific time. However there some request from the user to be able to run the Batch on the 'real' time using button.So I got an idea to just apply it as the same way I run in Apex Execute Anonymous. Requirement Steps: 1) Go to Setup -> Create -> Object . Choose the object you want to modify.Go to Buttons,Links and Action section.Click at N

Wondering about @future

What a hectic day: 18:04:53.589 (1589740000)|FATAL_ERROR|System.CalloutException: Callout from triggers are currently not supported. Actually I try to call a class (contain Http that retrieve data from external server) from trigger and retrieve the error above. Based on googling, it said something like this : to prevent exception above we need to add @future annotation at the top of our method like below. @future public static void executeSearch ( string criteria ) { String returnStr = '' ; String baseUrl = URL + ' / 2.0 / search ? format = xml & amp ; ' ; String [] searchArgs = new List & lt ; string & gt ;(); searchArgs . add ( criteria ); String relativeUrl = String . format ( ' criteria ={ 0 } ' , searchArgs ); HTTPRequest request = new HTTPRequest (); request . setEndpoint ( baseUrl + relativeUrl ); request .

Screaming for XMLStreamReader!!

I am studying on how to extract data from xml file.Actually I need to learn it for my project requirement.So I googling around and found these nice links. http:// salesforceapexcodecorner.blogspot.com http://blogs.developerforce.com http://it.toolbox.com/ Some of it using XMLStreamReader and some using XMLNode .But I choose to use XMLStreamReader.Why? I think it enough for my project requirement and for this time being I am able to understand XMLStreamReader better. If you refer to links above, most of it giving simple XML which only contain one element.During my self study, I am trying to read XML file whereby the element contains sub elements such as below <user xmlns:i= "http://www.w3.org/2001/XMLSchema-instance" > <id> 2262 </id> <displayname> Unidha </displayname> <email> unidha@yahoo.com </email> <usergroups> <usergroup><id> 301 </id><name> Administrators </name></use

Getting value from Custom Setting

I figured out how to getting value from custom setting. I know, I am too slow! :) . The purpose of custom setting can be read here .But my purpose is to store the Application configuration such as Key.In java , maybe I will store I create Custom Setting with details value: Label : Application Config Object Name: Application_Config__c  Setting Type : List  [Please go to here for more knowledge on List/Hierarchy differences] Visibility:Protected [I choose it by default] Once created, you will able to create custom fields.Last time I tried to create Name field without realize Name is default field. For this , I create one field named Value with API name Value__c . I inserted the data with Name : App_Name and Value__c : Health Monitoring . I just test in Apex Execute : String str1=Application_Config__c.getValues('App_Name').Value__c; system.debug('unid -'+str1); So that is how we can call custom setting value. Thanks.

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

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 . Sequence Meaning \n   or   \N New line \r   or   \R Carriage return \t   or   \T Tab \b   or   \B Bell \f   or   \F Form 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.:)

About sharing that I misunderstood

Sharing means caring literally.In salesforces, with sharing means I want to share based on the rules. By default, Apex class does not effected by  current user's permissions, field-level security, and sharing rules.Because it run in system context .Oh,please note this is not include Apex code that run in Execute Anonymous.Code in Execute Anonymous still effected by permission of the current user. So this is the reason why with sharing and without sharing keywords come for.But only to control sharing rules. Use with sharing to enforce the sharing rules that apply to the current user. Use without sharing  to ensure that the sharing rules for the current user are not enforced. How about if the class use neither with sharing or without sharing? Still the current sharing rules remain in effect. All the details can be check at Using the with sharing or without sharing Keywords . Actually why suddenly I babbling about sharing?Because it cause me headache  for almost who

Salesforce Actionstatus with JQuery Dialog box

I have a page which contains apex:component, custom (dynamic) tab in apex:page.The design is like this,each tab represent the category and each category have 3 text area.The tab is created in page level while the text areas is inside component level.Once the user navigate into different tab, the component will re render the text area for the related category. The user reported that whenever they update the textarea and quickly move to the different textarea or navigate into other tab, the data won't update correctly.I am thinking maybe because I use  actionSupport for every text area that calling the same method in Apex Controller which will update all the three text areas together. The quick workaround that I can think is to disable user to move or enter  new data before system complete processing the previous data.So I need to have something like indicator or progress bar like the one that I used to see in other applications.I need to use ActionStatus but it will be cooler

Generate JSON in Salesforce

I explore about JSON for generating pie chart in the site.I try this simple one, with hardcoded data. Requirement: 1)Apex Controller to prepare the data 2)Visual force page to display the data in JSON 1) Apex controller public class PieController { public String jsonString { get ; set ;} //Constructor public PieController () { jsonString = prepareData (); } //Temp Method to prepare the Data private String prepareData () { List & lt ; CompanyDetail & gt ; dtlObj = new List & lt ; CompanyDetail & gt ;(); CompanyDetail c1 = new CompanyDetail ( '1' , ' Samson ' , 30 ); CompanyDetail c2 = new CompanyDetail ( '2' , ' Targus ' , 35 ); CompanyDetail c3 = new CompanyDetail ( '3' , ' Swan ' , 60 ); CompanyDetail c4 = new CompanyDetail ( '4' , ' Filla ' , 30 ); dtlObj