09-12-2017 09:16 AM
I need to be able to read any object in Salesforce and write it out as a CSV file. To do this I need to be able to flatten the output dynamically.
Sample json:
[{
"Account_Class_vod__c" : "abc",
"ShippingAddress" : {
"city" : "aaa",
"country" : "Russia",
"countryCode" : null,
"geocodeAccuracy" : null,
"latitude" : null,
"longitude" : null,
"postalCode" : "306200",
"state" : "sss",
"stateCode" : null,
"street" : "st"
},
"Ownership" : "N"
}, {
"Account_Class_vod__c" : "abc",
"ShippingAddress" : {
"city" : "aaa",
"country" : "Russia",
"countryCode" : null,
"geocodeAccuracy" : null,
"latitude" : null,
"longitude" : null,
"postalCode" : "306200",
"state" : "sss",
"stateCode" : null,
"street" : "st"
},
"Ownership" : "N"
}, {
"Account_Class_vod__c" : "abc",
"ShippingAddress" : {
"city" : "aaa",
"country" : "Russia",
"countryCode" : null,
"geocodeAccuracy" : null,
"latitude" : null,
"longitude" : null,
"postalCode" : "306200",
"state" : "sss",
"stateCode" : null,
"street" : "st"
},
"Ownership" : "N"
}
]
Solved! Go to Solution.
10-02-2017 08:49 PM
We solve this by using a python script. I shared this under “Showcase” section. You can locate the “flattener” python script under Utilties / Collection of Python Scripts.
09-14-2017 08:03 PM
You can use mapper to change structure. Something like below:
I did changes for 2 fields only
09-18-2017 06:55 AM
Thank you for the mapper but my need is to do this dynamically. The data coming in to the mapper will not always be the same format. I’ll need to do this for a possible 850 salesforce objects all with different column names. I was thinking that a script snap would work but I’m not that strong in javascript, python, etc.
09-19-2017 09:34 PM
I am not following when you say dynamically.
Can you please elaborate with example.
09-26-2017 06:33 AM
The pipeline starts by listing all objects in salesforce and creates a SOQL statement for each object. The output from each object is different from the SOQL snap. In the above example data the Address field is not flat but in the second SOQL statement that runs could have 3 different fields that need to be flattened.