Posts Tagged ‘toolkit’

Time Zone issue with Salesforce toolkit for Flex

November 1, 2010

Use Case for GMT +5:30

If a date is saved having the time HH hours and minutes between 0 to 29, the force-flex.swc toolkit serializes this date with time zone offset having additional 1 hour difference. So the date saved in the database will have one hour difference than actual date sent. This is because the logic written in class of the toolkit is not considering the difference between UTC and local time when the difference in minutes is negative. So the resultant time zone has additional 1 hour offset.

Consider the following case:

A date passed to the dateTimeToString function in class in the toolkit is 16/02/2010 (mm/dd/yyyy format) and time 16 hours and 15 minutes.(Note the date specified is for GMT +5:30)

Date sent to Salesforce

The date after conversion is as shown in the soap message taken from httpfox tool of Mozilla firefox.

As seen from the soap message, the StartDateTime has the time zone set as +06:30 which is not the expected time zone.

Why this happens?

Consider the time for given date. Its 16 hours and 15 minutes.  When calculating time zone difference, the code in dateTimeToString function in neglects the negative difference between the minutes. When the user enters 16 hours and 15 minutes, it will be 10 hours and 45 minutes in GMT(UTC). But during calculation what is happening is the difference between the hours and minutes is directly considered as time zone offset which in this case will be 6 hours (16 – 10) and -30 minutes        (15 – 45). As the –ve sign for minutes difference is neglected, it is reflected as 1 hour additional difference in calculated hour for time zone.

Fix for the Bug

To fix the bug, just put a check in class in the function dateTimeToString as shown below:

Time Zone issue Fix

I hope someone will find this helpful as I spent 2 whole days figuring out what the problem was.


INVALID_FIELD: No such column ‘type’ error in flex salesforce communication

October 29, 2010

While trying to pass a custom object in salesforce from Flex. If you encounter the below error. Especially if you are passing a wrapper class to the webservice method.

“INVALID_FIELD: No such column ‘type’ on entity . If you are attempting to use a custom field, be sure to append the ‘__c’ after the custom field name. Please reference your WSDL or the describe call for the appropriate names.”

This occurs because the flex salesforce toolkit forces a property type while creating request parameters to be serialized with salesforce.

There are 2 solutions to this: First the not so attractive one is to convert everything to wrapper classes and send all data as SObjects. This will add overhead on salesforce  side to manage the conversion of object.

Second, go to Salesforce flex toolkit and add a condition to the SObject class on line 101:

this.writeValue(sobjectNs, writer, "type", this["type"]);

This should solve the issues of not being able to send the data to salesforce.

%d bloggers like this: