Legacy Dev Forum Posts

 View Only

Sign Up

Retrieve conditional output based on source input in DataAction

  • 1.  Retrieve conditional output based on source input in DataAction

    Posted 06-05-2025 18:44

    Artur_Dishunts | 2023-08-24 16:32:07 UTC | #1

    API returns array of objects where objects has userId and source property. The problem is when source equal to "Customer" then I don't have userId property, but if it is "Seller" then I can see userId. Here is my response config: { "translationMap": { "userId": "$[].[].userId", "source": "$[].[].source" }, "translationMapDefaults": { "userId": "null", "source": "null" }, "successTemplate": "{\"userId\": ${userId},\"source\": ${source}}" }

    Error message:

    11. Validate output against schema: JSON failed output schema validation for the following reasons: Schema: # @/properties/userId/items. Error location: /userId/0. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/1. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/2. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/3. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/4. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/5. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/6. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/7. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/8. instance type (null) does not match any allowed primitive type (allowed: ["string"]), Schema: # @/properties/userId/items. Error location: /userId/9. instance type (null) does not match any allowed primitive type (allowed: ["string"])


    Artur_Dishunts | 2023-08-24 18:51:42 UTC | #2

    There was similar problem Cycle on array in json response with template - Data Actions - Genesys Cloud Developer Forum. The solution is just changing type of the property that can be null.

    Before

    "userId": {
          "type": "array",
          "items": {
            "title": "userId",
            "type": "string"
          }
        }

    After

    "userId": {
          "type": "array",
          "items": {
            "title": "userId",
            "type": [
              "string",
              "null"
            ]
          }
        }

    system | 2023-09-24 18:52:31 UTC | #3

    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: 21693