Wednesday, July 27, 2011

CastIron and Scientific Notation

There is very little public help available online for CastIron orchestration development.  I was asked about this today and wanted to share the resolution.

A colleague observed that when using the Salesforce connector to retrieve an Account record, that the value returned in the AnnualRevenue field was presented in scientific notation.  When I read the email, I couldn't believe it but here is what he saw:


<?xml version="1.0" encoding="UTF-8"?>
- <Accounts>
   - <Account>
        <CrmAccountId>AC240012</CrmAccountId>
        <AccountName>Test 007</AccountName>
        <AccountRecordType>Legal Entity</AccountRecordType>
        <AnnualRevenue>1.0E7</AnnualRevenue>
        <NumberOfEmployees>5000</NumberOfEmployees>
        <Industry/>

Interestingly, he observed that the same SOQL run in Apex explorer yields: 10000000.
 
I setup a simple orchestration to verify this and determine a fix:
1. A polling activity set to 30 seconds
2. A Salesforce query activity to fetch the same Account record

In this screenshot you can see the simple orchestration.  In the verify pane on the right, you can see what is returned from salesforce via the connector.  Scientific notation!

I found that CastIron has some out-of-box formatting that can be applied.  In this case, I used the Number function, which takes any datatype and casts it as a number.  I think passed the output of the function to the Number format function to specify how I wanted to present the number.  In the verify pane, you can see the results:



Friday, July 8, 2011

Date Literals

Today, while debugging an orchestration, I came across a soql that contained this in where clause "LAST_N_DAYS:1".  I had not seen it before and searched the orchestration for where the variable was declared and found nothing.  I thought it might be something specific to CastIron but after a quick google search, it turned up in the salesforce documentation:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm

So, if you needed to find all of the opportunities that were updated in the last 10 days, you could write something like this: select o.Id from Opportunity o where o.LastModifiedDate >= LAST_N_DAYS:10

And the documentation has a bunch of other Date Literals that should be very handy!