Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Default response config (returns an array that can't be flattened):
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "translationMap": {
- "contact": "$.searchRecords"
- },
- "successTemplate": "${contact}"
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Response config with successTemplate that (1) puts array in an object and (2) names the array (required for flattening):
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "translationMap": {
- "contact": "$.searchRecords"
- },
- "successTemplate": "{\"contacts\": ${contact}}"
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Response from Salesforce
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "searchRecords": [
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1951-02-17",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Description": null,
- "Email": "barr_tim@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "Tim",
- "HomePhone": null,
- "Id": "003f4000002Jt62AAC",
- "IsDeleted": false,
- "LastName": "Barr",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "city": null,
- "country": null,
- "geocodeAccuracy": null,
- "latitude": null,
- "longitude": null,
- "postalCode": null,
- "state": null,
- "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingCity": null,
- "MailingCountry": null,
- "MailingPostalCode": null,
- "MailingState": null,
- "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1230",
- "Name": "Tim Barr",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "SVP, Administration and Finance"
- },
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1953-04-30",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Description": null,
- "Email": "bond_john@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "John",
- "HomePhone": null,
- "Id": "003f4000002Jt63AAC",
- "IsDeleted": false,
- "LastName": "Bond",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "city": null,
- "country": null,
- "geocodeAccuracy": null,
- "latitude": null,
- "longitude": null,
- "postalCode": null,
- "state": null,
- "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingCity": null,
- "MailingCountry": null,
- "MailingPostalCode": null,
- "MailingState": null,
- "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1563",
- "Name": "John Bond",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "VP, Facilities"
- }
- ]
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Output from default successTemplate (will not flatten)
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- [
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1951-02-17",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Email": "barr_tim@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "Tim",
- "Id": "003f4000002Jt62AAC",
- "IsDeleted": false,
- "LastName": "Barr",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1230",
- "Name": "Tim Barr",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "SVP, Administration and Finance"
- },
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1953-04-30",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Email": "bond_john@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "John",
- "Id": "003f4000002Jt63AAC",
- "IsDeleted": false,
- "LastName": "Bond",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1563",
- "Name": "John Bond",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "VP, Facilities"
- }
- ]
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Output from updated successTemplate (note object "envelope" and named array)
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "contacts": [
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1951-02-17",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Email": "barr_tim@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "Tim",
- "Id": "003f4000002Jt62AAC",
- "IsDeleted": false,
- "LastName": "Barr",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1230",
- "Name": "Tim Barr",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "SVP, Administration and Finance"
- },
- {
- "attributes": {
- "type": "Contact",
- "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
- },
- "AccountId": "001f4000003FE0UAAW",
- "Birthdate": "1953-04-30",
- "CreatedDate": "2017-07-11T16:31:15.000+0000",
- "Email": "bond_john@grandhotels.com",
- "Fax": "(312) 596-1500",
- "FirstName": "John",
- "Id": "003f4000002Jt63AAC",
- "IsDeleted": false,
- "LastName": "Bond",
- "LeadSource": "External Referral",
- "MailingAddress": {
- "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- },
- "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "MobilePhone": "(312) 596-1563",
- "Name": "John Bond",
- "OwnerId": "005f4000000Yq3cAAC",
- "Phone": "(312) 596-1000",
- "Salutation": "Mr.",
- "Title": "VP, Facilities"
- }
- ]
- }
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- Successful flattened response (using updated successTemplate)
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- {
- "contacts.MailingStreet": [
- "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- ],
- "contacts.attributes.url": [
- "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC",
- "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
- ],
- "contacts.Fax": [
- "(312) 596-1500",
- "(312) 596-1500"
- ],
- "contacts.Title": [
- "SVP, Administration and Finance",
- "VP, Facilities"
- ],
- "contacts.CreatedDate": [
- "2017-07-11T16:31:15.000+0000",
- "2017-07-11T16:31:15.000+0000"
- ],
- "contacts.attributes.type": [
- "Contact",
- "Contact"
- ],
- "contacts.LastName": [
- "Barr",
- "Bond"
- ],
- "contacts.Email": [
- "barr_tim@grandhotels.com",
- "bond_john@grandhotels.com"
- ],
- "contacts.FirstName": [
- "Tim",
- "John"
- ],
- "contacts.Id": [
- "003f4000002Jt62AAC",
- "003f4000002Jt63AAC"
- ],
- "contacts.IsDeleted": [
- false,
- false
- ],
- "contacts.Salutation": [
- "Mr.",
- "Mr."
- ],
- "contacts.Phone": [
- "(312) 596-1000",
- "(312) 596-1000"
- ],
- "contacts.AccountId": [
- "001f4000003FE0UAAW",
- "001f4000003FE0UAAW"
- ],
- "contacts.MobilePhone": [
- "(312) 596-1230",
- "(312) 596-1563"
- ],
- "contacts.Name": [
- "Tim Barr",
- "John Bond"
- ],
- "contacts.LeadSource": [
- "External Referral",
- "External Referral"
- ],
- "contacts.Birthdate": [
- "1951-02-17",
- "1953-04-30"
- ],
- "contacts.MailingAddress.street": [
- "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
- "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
- ],
- "contacts.OwnerId": [
- "005f4000000Yq3cAAC",
- "005f4000000Yq3cAAC"
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement