ottoflux | 2019-07-26 21:15:42 UTC | #1
Hi all - I have a flattened array coming back (yes, I read https://developer.mypurecloud.com/forum/t/process-multiple-array-of-contacts-or-accounts-from-a-salesforce-data-action/2274 ) but I'm trying to figure out what sort of fiddling I have to do in the translation (I suppose) to have contact1.name, contact2.name accessible in Architect.
Perhaps I'm missing something obvious, but it's Friday and I didn't see anything in the forum that shows a good example of it. If there isn't one and it can be done, I suppose I'll try to write up a post showing how to do it but I thought I'd check first.
Jason_Mathison | 2019-07-29 12:49:28 UTC | #2
Hey Jason,
Can you export your data action and include a (sanitized if needed) example of the response you are trying to handle?
--Jason
ottoflux | 2019-07-30 20:02:31 UTC | #3
It's cool - I just wanted to know if there was a sample of pulling N elements out, there wasn't and so I figured it out. Just haven't done that much JSON on a regular basis. I'll probably type up a generic example complete with contracts, data translation map, and defaults. It can come in handy for doing just one call over to Salesforce (or somewhere else) saying give me the contacts for "317222222" and then evaluate whether contact2id is the default value or not (and same for contact1id) in architect to make only one round trip web service call.
ottoflux | 2019-07-31 13:42:52 UTC | #4
<a class="attachment" href="/forum/uploads/db6296/original/2X/2/2f895312afd42e97e7bceb3f437fe0695f0240f4.json">Get-Users-from-Mockable-20190730180152.custom.json</a> (6.2 KB)
So I set up a mockable and I'm thinking about writing a HOWTO part 2 to show people how to set up the mapping, etc. Care to take a peek and tell me if I've done anything overkill? What I did in my actual use case was just map through to the 2nd user ID because if we get multiple matches we don't care about the value and want to prompt the user for more information to narrow it down. I set up a mockable REST response to mimic (to an extent) the Salesforce responses so it can be tested, etc. The values you pass it in test are "multi" "single" or "zero".
ottoflux | 2019-08-06 18:55:19 UTC | #5
Hey there - Just checking in to see if there's anything you'd change with my sample before I toss it out there. I'd rather it be useful without overkill.
Thanks, Jason
Jason_Mathison | 2019-08-07 14:27:03 UTC | #6
The way we expected situations like this to be handled is quite a bit different, assuming that the object returned from the web service isn't so complicated that it breaks flattening.
In this case I setup the output contract to model the object being returned by your mockable endpoint and eliminated all translation map and success template customizations.
Inside of architect what you will see is that all of the outputs from your action will have names like searchRecords.BalanceDue and searchRecords.Name. Those variables will be a list of the underlying datatype, like string for "name" or boolean for "active".
Inside of architect you can detect 0/1/many results by checking the size of any of the lists.
The trick here is that when flattening is in use (which is required for Architect), we only allow one result to be returned, not an array with multiple items. In this case, "searchRecords" is the one result, which happens to have an array of objects in it.
Hopefully this handles your use case with a lot less customization required.
<a class="attachment" href="/forum/uploads/db6296/original/2X/3/3b2200638f7e579f04cd0f90892d8a120d68bc93.json">Get-Users-from-Mockable.json</a> (2.2 KB)
ottoflux | 2019-08-07 15:03:04 UTC | #7
Thanks - was there somewhere I should have gleaned that from documentation, or is it worth me typing up a howto using your modification of my example?
ottoflux | 2019-08-08 13:51:00 UTC | #8
So basically, just define the object well and then use the "additionalProperties": true to allow for multiples.
Cool - that saves a lot of time. I'll try to write this up into a more fluid example when I free up.
ottoflux | 2019-08-08 13:51:20 UTC | #9
(and thank you again)
system | 2019-09-08 13:51:21 UTC | #10
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5647