Posts

Showing posts from May, 2014

Salesforce trigger hell-1

Problem Many a time we see that the errors added by trigger's, are being shown to user in the below format, which are not user friendly and user's complain about that. Error: Invalid Data.  Review all error messages below to correct your data. Apex trigger validateLastname caused an unexpected exception, contact your administrator: validateLastname: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, no child allowed: Trigger.validateLastname: line 6, column 1 Root cause Whenever error with the line number is shown to user, you can be sure that this is un-handled exception. And it comes basically when you have fired another DML inside any trigger, and that DML is failed.  Let's understand this by scenario. Scenario  Let's assume that User is trying to save a record of OBJ1 from User interface. and you have written a trigger on OBJ1, which on certain cond...

Inserting date fields by data loader

This post answers the following question What should be the date format while uploading by data loader Its always tough to upload the dates/date time through data loader due to the lack of proper documentation. Below table shows the exact format while uploading dates/datetimes through data loader. Also find the URL below for more details. Format Format  Syntax Example Date  only YYYY-MM-DD 1999-01-01 Date , time, and time zone offset YYYY-MM-DDThh:mm:ss+hh:mm YYYY-MM-DDThh:mm:ss-hh:mm YYYY-MM-DDThh:mm:ssZ 1999-01-01T23:01:01+01:00 1999-01-01T23:01:01-08:00 1999-01-01T23:01:01Z here's a link to the guide:  http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_soql.htm

apex HTML pass through not working

Pass through attribute doesn't generate proper html HTML Pass through provided by salesforce in VF pages has been very useful when working with javascript libraries, However while working on the same I came across a situation where Pass through attribute doesn't get passed to generated html if the binding variable is 'Currency' type. Below is the example. Controller 1: public Opportunity Oppty {get;set;} VF page 1: <apex:outputField value = '{!Oppty.Amount}' html-passedValue='XYZ'></apex:outputField> Generated html 1: <span id="j_id0:j_id1:j_id14">$20</span> Hence you can see that the pass through attribute is not generated. However if you change the binding variable to any type other then Currency, pass through will start working. as shown below. VF page 1: <apex:outputField value = '{!Oppty.name}' html-passedValue='XYZ'></apex:outputField> ...