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:



No comments:

Post a Comment