Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
2,442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.85 KB | None | 0 0
  1.  
  2. ///////////////////////////////////////////////////////////////////////////////////////////////////
  3. Default response config (returns an array that can't be flattened):
  4. ///////////////////////////////////////////////////////////////////////////////////////////////////
  5. {
  6. "translationMap": {
  7. "contact": "$.searchRecords"
  8. },
  9. "successTemplate": "${contact}"
  10. }
  11.  
  12.  
  13. ///////////////////////////////////////////////////////////////////////////////////////////////////
  14. Response config with successTemplate that (1) puts array in an object and (2) names the array (required for flattening):
  15. ///////////////////////////////////////////////////////////////////////////////////////////////////
  16. {
  17. "translationMap": {
  18. "contact": "$.searchRecords"
  19. },
  20. "successTemplate": "{\"contacts\": ${contact}}"
  21. }
  22.  
  23.  
  24.  
  25. ///////////////////////////////////////////////////////////////////////////////////////////////////
  26. Response from Salesforce
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. {
  29. "searchRecords": [
  30. {
  31. "attributes": {
  32. "type": "Contact",
  33. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
  34. },
  35. "AccountId": "001f4000003FE0UAAW",
  36. "Birthdate": "1951-02-17",
  37. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  38. "Description": null,
  39. "Email": "barr_tim@grandhotels.com",
  40. "Fax": "(312) 596-1500",
  41. "FirstName": "Tim",
  42. "HomePhone": null,
  43. "Id": "003f4000002Jt62AAC",
  44. "IsDeleted": false,
  45. "LastName": "Barr",
  46. "LeadSource": "External Referral",
  47. "MailingAddress": {
  48. "city": null,
  49. "country": null,
  50. "geocodeAccuracy": null,
  51. "latitude": null,
  52. "longitude": null,
  53. "postalCode": null,
  54. "state": null,
  55. "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  56. },
  57. "MailingCity": null,
  58. "MailingCountry": null,
  59. "MailingPostalCode": null,
  60. "MailingState": null,
  61. "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  62. "MobilePhone": "(312) 596-1230",
  63. "Name": "Tim Barr",
  64. "OwnerId": "005f4000000Yq3cAAC",
  65. "Phone": "(312) 596-1000",
  66. "Salutation": "Mr.",
  67. "Title": "SVP, Administration and Finance"
  68. },
  69. {
  70. "attributes": {
  71. "type": "Contact",
  72. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
  73. },
  74. "AccountId": "001f4000003FE0UAAW",
  75. "Birthdate": "1953-04-30",
  76. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  77. "Description": null,
  78. "Email": "bond_john@grandhotels.com",
  79. "Fax": "(312) 596-1500",
  80. "FirstName": "John",
  81. "HomePhone": null,
  82. "Id": "003f4000002Jt63AAC",
  83. "IsDeleted": false,
  84. "LastName": "Bond",
  85. "LeadSource": "External Referral",
  86. "MailingAddress": {
  87. "city": null,
  88. "country": null,
  89. "geocodeAccuracy": null,
  90. "latitude": null,
  91. "longitude": null,
  92. "postalCode": null,
  93. "state": null,
  94. "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  95. },
  96. "MailingCity": null,
  97. "MailingCountry": null,
  98. "MailingPostalCode": null,
  99. "MailingState": null,
  100. "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  101. "MobilePhone": "(312) 596-1563",
  102. "Name": "John Bond",
  103. "OwnerId": "005f4000000Yq3cAAC",
  104. "Phone": "(312) 596-1000",
  105. "Salutation": "Mr.",
  106. "Title": "VP, Facilities"
  107. }
  108. ]
  109. }
  110.  
  111. ///////////////////////////////////////////////////////////////////////////////////////////////////
  112. Output from default successTemplate (will not flatten)
  113. ///////////////////////////////////////////////////////////////////////////////////////////////////
  114.  
  115. [
  116. {
  117. "attributes": {
  118. "type": "Contact",
  119. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
  120. },
  121. "AccountId": "001f4000003FE0UAAW",
  122. "Birthdate": "1951-02-17",
  123. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  124. "Email": "barr_tim@grandhotels.com",
  125. "Fax": "(312) 596-1500",
  126. "FirstName": "Tim",
  127. "Id": "003f4000002Jt62AAC",
  128. "IsDeleted": false,
  129. "LastName": "Barr",
  130. "LeadSource": "External Referral",
  131. "MailingAddress": {
  132. "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  133. },
  134. "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  135. "MobilePhone": "(312) 596-1230",
  136. "Name": "Tim Barr",
  137. "OwnerId": "005f4000000Yq3cAAC",
  138. "Phone": "(312) 596-1000",
  139. "Salutation": "Mr.",
  140. "Title": "SVP, Administration and Finance"
  141. },
  142. {
  143. "attributes": {
  144. "type": "Contact",
  145. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
  146. },
  147. "AccountId": "001f4000003FE0UAAW",
  148. "Birthdate": "1953-04-30",
  149. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  150. "Email": "bond_john@grandhotels.com",
  151. "Fax": "(312) 596-1500",
  152. "FirstName": "John",
  153. "Id": "003f4000002Jt63AAC",
  154. "IsDeleted": false,
  155. "LastName": "Bond",
  156. "LeadSource": "External Referral",
  157. "MailingAddress": {
  158. "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  159. },
  160. "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  161. "MobilePhone": "(312) 596-1563",
  162. "Name": "John Bond",
  163. "OwnerId": "005f4000000Yq3cAAC",
  164. "Phone": "(312) 596-1000",
  165. "Salutation": "Mr.",
  166. "Title": "VP, Facilities"
  167. }
  168. ]
  169.  
  170. ///////////////////////////////////////////////////////////////////////////////////////////////////
  171. Output from updated successTemplate (note object "envelope" and named array)
  172. ///////////////////////////////////////////////////////////////////////////////////////////////////
  173. {
  174. "contacts": [
  175. {
  176. "attributes": {
  177. "type": "Contact",
  178. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC"
  179. },
  180. "AccountId": "001f4000003FE0UAAW",
  181. "Birthdate": "1951-02-17",
  182. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  183. "Email": "barr_tim@grandhotels.com",
  184. "Fax": "(312) 596-1500",
  185. "FirstName": "Tim",
  186. "Id": "003f4000002Jt62AAC",
  187. "IsDeleted": false,
  188. "LastName": "Barr",
  189. "LeadSource": "External Referral",
  190. "MailingAddress": {
  191. "street": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  192. },
  193. "MailingStreet": "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  194. "MobilePhone": "(312) 596-1230",
  195. "Name": "Tim Barr",
  196. "OwnerId": "005f4000000Yq3cAAC",
  197. "Phone": "(312) 596-1000",
  198. "Salutation": "Mr.",
  199. "Title": "SVP, Administration and Finance"
  200. },
  201. {
  202. "attributes": {
  203. "type": "Contact",
  204. "url": "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
  205. },
  206. "AccountId": "001f4000003FE0UAAW",
  207. "Birthdate": "1953-04-30",
  208. "CreatedDate": "2017-07-11T16:31:15.000+0000",
  209. "Email": "bond_john@grandhotels.com",
  210. "Fax": "(312) 596-1500",
  211. "FirstName": "John",
  212. "Id": "003f4000002Jt63AAC",
  213. "IsDeleted": false,
  214. "LastName": "Bond",
  215. "LeadSource": "External Referral",
  216. "MailingAddress": {
  217. "street": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  218. },
  219. "MailingStreet": "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  220. "MobilePhone": "(312) 596-1563",
  221. "Name": "John Bond",
  222. "OwnerId": "005f4000000Yq3cAAC",
  223. "Phone": "(312) 596-1000",
  224. "Salutation": "Mr.",
  225. "Title": "VP, Facilities"
  226. }
  227. ]
  228. }
  229.  
  230. ///////////////////////////////////////////////////////////////////////////////////////////////////
  231. Successful flattened response (using updated successTemplate)
  232. ///////////////////////////////////////////////////////////////////////////////////////////////////
  233. {
  234. "contacts.MailingStreet": [
  235. "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  236. "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  237. ],
  238. "contacts.attributes.url": [
  239. "/services/data/v37.0/sobjects/Contact/003f4000002Jt62AAC",
  240. "/services/data/v37.0/sobjects/Contact/003f4000002Jt63AAC"
  241. ],
  242. "contacts.Fax": [
  243. "(312) 596-1500",
  244. "(312) 596-1500"
  245. ],
  246. "contacts.Title": [
  247. "SVP, Administration and Finance",
  248. "VP, Facilities"
  249. ],
  250. "contacts.CreatedDate": [
  251. "2017-07-11T16:31:15.000+0000",
  252. "2017-07-11T16:31:15.000+0000"
  253. ],
  254. "contacts.attributes.type": [
  255. "Contact",
  256. "Contact"
  257. ],
  258. "contacts.LastName": [
  259. "Barr",
  260. "Bond"
  261. ],
  262. "contacts.Email": [
  263. "barr_tim@grandhotels.com",
  264. "bond_john@grandhotels.com"
  265. ],
  266. "contacts.FirstName": [
  267. "Tim",
  268. "John"
  269. ],
  270. "contacts.Id": [
  271. "003f4000002Jt62AAC",
  272. "003f4000002Jt63AAC"
  273. ],
  274. "contacts.IsDeleted": [
  275. false,
  276. false
  277. ],
  278. "contacts.Salutation": [
  279. "Mr.",
  280. "Mr."
  281. ],
  282. "contacts.Phone": [
  283. "(312) 596-1000",
  284. "(312) 596-1000"
  285. ],
  286. "contacts.AccountId": [
  287. "001f4000003FE0UAAW",
  288. "001f4000003FE0UAAW"
  289. ],
  290. "contacts.MobilePhone": [
  291. "(312) 596-1230",
  292. "(312) 596-1563"
  293. ],
  294. "contacts.Name": [
  295. "Tim Barr",
  296. "John Bond"
  297. ],
  298. "contacts.LeadSource": [
  299. "External Referral",
  300. "External Referral"
  301. ],
  302. "contacts.Birthdate": [
  303. "1951-02-17",
  304. "1953-04-30"
  305. ],
  306. "contacts.MailingAddress.street": [
  307. "2335 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA",
  308. "2334 N. Michigan Avenue, Suite 1500\nChicago, IL 60601, USA"
  309. ],
  310. "contacts.OwnerId": [
  311. "005f4000000Yq3cAAC",
  312. "005f4000000Yq3cAAC"
  313. ]
  314. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement