melissalsmith | 2020-03-12 23:48:17 UTC | #1
We are using a data action in our call flow to look up to Dynamics with the ANI as the input and output the first "Contact" record that we have with that ANI.
The issue is that we have multiple contact records that could possibly be returned for a single ANI. What we would like to do is return only the first record that is returned. Any thoughts on how to make this work? Below is what we have so far:
When testing the data action, we get the desired result when we deselect "Flatten output":
When "Flatten output" is selected, we get, "Too many results matched criteria".
When I add the data action to our call flow to test, it continually fails to return a record because it is running as "flattened" by default.
Request URL: /api/data/v8.1/contacts?${esc.dollar}select=contactid,parentcustomeridvalue,owninguservalue,firstname,lastname,nickname,address1telephone1,address1telephone2,mobilephone,address1line1,address1line2,address1city,address1stateorprovince,address1postalcode,address1country&${esc.d}filter=$esc.url($msdynamics.phoneNumberFilter("$input.PHONENUMBER", ["address1telephone1", "address1_telephone2", "mobilephone"]))
Input Contract: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Phone Number Request", "description": "A phone number-based request.", "type": "object", "required": [ "PHONENUMBER" ], "properties": { "PHONENUMBER": { "description": "The phone number used for the query.", "type": "string" }, "address1telephone1": { "description": "The phone number used for the query", "type": "string" }, "address1telephone2": { "description": "The phone number used for the query", "type": "string" }, "mobilephone": { "description": "The phone number used for the query", "type": "string" } }, "additionalProperties": true }
Output contract: { "type": "array", "properties": {}, "items": { "title": "Contact", "type": "object", "properties": { "owninguservalue": { "type": "string" }, "contactid": { "type": "string" }, "firstname": { "type": "string" }, "lastname": { "type": "string" }, "address1_stateorprovince": { "type": "string" } }, "additionalProperties": true } }
Jason_Mathison | 2020-03-13 01:21:00 UTC | #2
The trick is going to be to use a translation map to extract the first contact out of the results using a translationMap, and then using the variable that you pull out in your response template.
This page will walk you through the configuration side of things: https://help.mypurecloud.com/articles/response-configuration-data-actions/
And I typically use http://jsonpath.com/ to nail down the JSONPath that I use in the translation map. One warning, if you stray off into invalid JSONPath the UI doesn't really warn you, it just leaves the output unchanged, which can be quite confusing.
If you work at this a while and can't come up with a solution please post what you are trying as an export of your action and an example of the what is being returned by the "execution" step of test mode, with any sensitive stuff redacted. Please make sure that all of the {}s and []s are unchanged.
--Jason
melissalsmith | 2020-03-26 02:28:20 UTC | #3
Thanks Jason, I'm looking into this and will let you know how it goes.
system | 2020-04-26 02:28:22 UTC | #4
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: 7334