Thursday, December 19, 2013

Passing date (e.g. Task's ActivityDate) on Salesforce Webservice

I was getting "due date - value is not of the required type" error message from Salesforce Webservice when trying to create a Task object. After a bit try and error, herewith is a solution...

1. Salesforce Webservice is expecting a date string in xsd:date format - "yyyy-mm-dd"
2. The date string can't be passed as a simple string, a SoapPrimitive is required instead.

the code looks like ...
SoapPrimitive aDate=new SoapPrimitive("http://www.w3.org/2001/XMLSchema", "date", "2010-12-13");
aSObject.addProperty("ActivityDate", aDate);