Assistance Needed With A Data Actions Output

Hello,

Wondering if anyone can point me in the right direction, please.

I am trying to get the accountId from the response, however, it is not being assigned to the output and I am not sure why that is.

Here is a snippet of the output schema.

The success template is as follows.

{
  "translationMap": {
    "accountId": "summary.accountId"
  },
  "translationMapDefaults": {
    "accountId": ""
  },
  "successTemplate": "{\n   \"accountId\": ${accountId}\n}"
}

Here is the test run, how do I get the accountId as an output?

Thank you.

Hi Chris,

Your output contract is for an object like

{
   "summary" : {
      "accountId: "foo",
      "brand" : "bar"
   }
}

However the output you are creating is this:

{
   "accountId: "foo",
}

So you you need to account for the outer "summary" object in your success template.

--Jason

Thanks Jason, are you able show me an example as I am struggling to get it working, Please. If possible.

This is my latest map

{
  "translationMap": {
    "summary.accountId": "summary.accountId"
  },
  "translationMapDefaults": {
    "summary.accountId": ""
  },
  "successTemplate": "{\n   \"summary\": {\n       \"accountId\": ${summary.accountId}\n   }\n}"
}

Thank you.

@Chris_Carr - I am not sure what the output from you API looks like but if it looks like this:

{
   "accountId": "foo"
}

Then your translation map would be:

{
  "translationMap": {
    "summary.accountId": "$.accountId"
  },
  "translationMapDefaults": {
    "summary.accountId": ""
  },
  "successTemplate": "{\n   \"summary\": {\n       \"accountId\": ${summary.accountId}\n   }\n}"
}

I use this tool to work out the JSONPath required for translation mapping. https://jsonpath.com/

Thanks,
Darren

Hello,

Thank you. I'm afraid I am still stuck and hoping you can help.

This is the response

{
  "summary": {
"accountId": "555555",
"internalCRMId": "555555",
"brand": "brand",
"billingSystem": "bill_sys",
"wasCRM": false,
"lifecycleCategory": "Unknown"
  },
  "lifecycle": {
"earliestContractRenewal": "2024-11-16",
"latestSupplyStart": "2015-07-02"
  },
  "comms": {
"openComplaintCount": 0,
"lastCommDate": "2023-03-06",
"commsInLast14Days": [
  {
    "templateName": "Temp1",
    "dateSent": "2023-03-06"
  },
  {
    "templateName": "Temp2",
    "dateSent": "2023-03-06"
  }
],
"collectionHistoryInLast14Days": []
  },
  "billing": {
"balancePence": 55555,
"lastBillDate": "2023-03-06"
  },
  "smartInstall": {
"complete": false,
"bookedDate": "2022-09-07"
  },
  "isOnPSR": true,
  "psr": {
"vulnerabilities": [
  "vuln1",
  "vuln2",
  "vuln3",
  "vuln4",
  "vuln5"
],
"activeTemporaryVulnerabilities": [],
"services": [
  "serv1",
  "serv2",
  "serv3"
]
  },
  "isFirstTimeDebtor": false
}

This is my successTemplate

  "translationMap": {
"summary.accountId": "$.summary.accountId"
  },
  "translationMapDefaults": {
"summary.accountId": ""
  },
  "successTemplate": "{\n \"summary\": {\n \"accountId\": ${summary.accountId} \n}\n}"
}

This is the error that I get

{
  "message": "Transform failed to process result using 'successTemplate' template due to error:'Variable $summary has not been set at successTemplate[line 3, column 15]'\n Template:'{\n \"summary\": {\n \"accountId\": ${summary.accountId} \n}\n}'.",
  "code": "bad.request",
  "status": 400,
  "messageParams": {},
  "contextId": "73783934-72e8-467e-abac-cdd31fca7c4e",
  "details": [
{
  "errorCode": "ACTION.PROCESSING"
}
  ],
  "errors": []
}

Thank you.

Hey Chris,

It looks like you ran into an area where we could be a lot more helpful. It turns out that your variable name 'summary.accountId' is not legal. Here are the rules for valid Velocity variable names:

A VTL Identifier must start with an alphabetic character (a .. z or A .. Z). The rest of the characters are limited to the following types of characters:

  • alphabetic (a .. z, A .. Z)
  • numeric (0 .. 9)
  • hyphen ("-")
  • underscore ("_")

Replacing 'summary.accountId' with 'accountId' in your translationMap, defaults, and success template will get you going.

I am opening up a ticket for us to validate the variable names and give you a helpful error message if a variable name isn't valid. I really hate it when someone ends up discouraged like this, please keep letting us know if you run into any more rough edges.

--Jason

Hi Jason,

Thank you very much, it is probably more me being silly. I normally create my actions with a single response object so this one is a bit different.

Did you mean amend it as per the below?

{
  "translationMap": {
    "accountId": "$.accountId"
  },
  "translationMapDefaults": {
    "accountId": ""
  },
  "successTemplate": "{\n \"accountId\": ${accountId} \n}"
}

The jsonPath of "$.summary.accountId" was correct. It is the variable that it gets stored into that needs to have the dot removed.

--Jason

Hi Jase,

Brilliant, thank you!! so that works and I get the response but it does not map to the "accountId" output but does return the correct value. This is how I had it when I initially raised the post if I remember correctly :slight_smile:

{
"translationMap": {
  "accountId": "$.summary.accountId"
},
"translationMapDefaults": {
  "accountId": ""
},
"successTemplate": "{\n \"summary\": {\n \"accountId\": ${accountId} \n}\n}"
}

Sorry if I am being really silly and appreciate the assistance.

Kind Regards,

Hi Jason,

I have also tried the below and have the same situation.

{
  "translationMap": {
    "accountId": "$.summary.accountId"
  },
  "translationMapDefaults": {
    "accountId": ""
  },
  "successTemplate": "{\n \"accountId\": ${accountId}\n}"
}

Thank you.

Kind Regards,
Chris

What is your output contract configured to expect?

Hi Jason,

Thank you. This is a screenshot of the account id

This is the entire output schema.

{
  "title": "Lookup Account Details Response",
  "type": "object",
  "properties": {
    "summary": {
      "type": "object",
      "properties": {
        "accountId": {
          "type": "string"
        },
        "brand": {
          "type": "string"
        },
        "billingSystem": {
          "type": "string"
        },
        "accountManagementTeam": {
          "type": "object",
          "properties": {
            "teamId": {
              "type": "string"
            },
            "teamName": {
              "type": "string"
            },
            "emailQueue": {
              "type": "string"
            },
            "phoneQueue": {
              "type": "string"
            },
            "whatsAppQueue": {
              "type": "string"
            }
          },
          "additionalProperties": true
        },
        "paymentMethod": {
          "type": "string"
        },
        "undefined": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "billing": {
      "type": "object",
      "properties": {
        "balancePence": {
          "type": "number"
        },
        "lastBillDate": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "lifecycle": {
      "type": "object",
      "properties": {
        "earliestContractRenewal": {
          "type": "string"
        },
        "latestSupplyStart": {
          "type": "string"
        },
        "BillingStartDate": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "comms": {
      "type": "object",
      "properties": {
        "openComplaintCount": {
          "type": "integer"
        },
        "lastCommDate": {
          "type": "string"
        },
        "collectionHistoryInLast14Days": {
          "type": "array",
          "items": [
            {
              "title": "Item 1",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            },
            {
              "title": "Item 2",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            },
            {
              "title": "Item 3",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          ]
        },
        "commsInLast14Days": {
          "type": "array",
          "items": [
            {
              "title": "Item 1",
              "type": "object",
              "properties": {},
              "additionalProperties": true
            },
            {
              "title": "Item 2",
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          ]
        }
      },
      "additionalProperties": true
    },
    "smartInstall": {
      "type": "object",
      "properties": {
        "complete": {
          "type": "boolean"
        },
        "eligible": {
          "type": "boolean"
        },
        "bookedDate": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "isOnPSR": {
      "type": "boolean"
    },
    "isFirstTimeDebtor": {
      "type": "boolean"
    },
    "psr": {
      "type": "object",
      "properties": {
        "vulnerabilities": {
          "type": "array",
          "items": [
            {
              "title": "Item 1",
              "type": "string"
            },
            {
              "title": "Item 2",
              "type": "string"
            },
            {
              "title": "Item 3",
              "type": "string"
            },
            {
              "title": "Item 4",
              "type": "string"
            },
            {
              "title": "Item 5",
              "type": "string"
            },
            {
              "title": "Item 6",
              "type": "string"
            },
            {
              "title": "Item 7",
              "type": "string"
            },
            {
              "title": "Item 8",
              "type": "string"
            },
            {
              "title": "Item 9",
              "type": "string"
            },
            {
              "title": "Item 10",
              "type": "string"
            }
          ]
        },
        "services": {
          "type": "array",
          "items": [
            {
              "title": "Item 1",
              "type": "string"
            },
            {
              "title": "Item 2",
              "type": "string"
            },
            {
              "title": "Item 3",
              "type": "string"
            },
            {
              "title": "Item 4",
              "type": "string"
            },
            {
              "title": "Item 5",
              "type": "string"
            },
            {
              "title": "Item 6",
              "type": "string"
            },
            {
              "title": "Item 7",
              "type": "string"
            },
            {
              "title": "Item 8",
              "type": "string"
            },
            {
              "title": "Item 9",
              "type": "string"
            },
            {
              "title": "Item 10",
              "type": "string"
            }
          ]
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}

If you remove the "comms" and "psr" blocks of your output schema the UI will start showing results correctly. Please open up a support case for this issue so we can investigate and resolve it.

--Jason

Hi Chris,

Was this generated by a schema generator by chance?

Our current guess is that you generated this schema from an example response that had 3 items in the collectionHistoryInLast14Days array. The schema generator didn't notice that all three items had the same shape, instead it created an array of possible types for this array, all of which are the same.

So, to get your schema working, you would have to replace any place you have an items array with an items object. For example replacing this:

"collectionHistoryInLast14Days": {
          "type": "array",
          "items": [
            {
              "title": "Item 1",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            },
            {
              "title": "Item 2",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            },
            {
              "title": "Item 3",
              "type": "object",
              "properties": {
                "actionOutcomeCode": {
                  "type": "string"
                },
                "actionOutcomeSubCode": {
                  "type": "string"
                },
                "dateTimeAdded": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          ]
        },

with something like this:

"collectionHistoryInLast14Days": {
	"type": "array",
	"items": {
		"title": "Item 1",
		"type": "object",
		"properties": {
			"actionOutcomeCode": {
				"type": "string"
			},
			"actionOutcomeSubCode": {
				"type": "string"
			},
			"dateTimeAdded": {
				"type": "string"
			}
		},
		"additionalProperties": true
	}
}

We may try to handle this more gracefully in the future, but for now this fix seems to be the fastest solution for your problem.
--Jason

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.