Forum Discussion
Fail Message Not Working in Fail Activity
Hi arehman36,
I think there are two expression issues worth checking here.
Your first Lookup returns multiple rows in output.value, and the ForEach is presumably iterating over that array.
Because of that, inside the ForEach I would not use:
activity('LookupGetTableList').output.SchemaTableNameThe current table should be taken from the current ForEach item instead:
item().SchemaTableNameMicrosoft's Lookup activity documentation explains that multi-row Lookup results are returned under the value array, and the ForEach documentation uses item() to access the row currently being processed.
Your two column-count Lookups also return their values under firstRow.
So based on the output you posted, the Fail message would look conceptually like this:
@concat(
'Columns do not match. On-premise table column count: ',
string(activity('OnPremColumnCount').output.firstRow.OnPremColumnCount),
'. Cloud table column count: ',
string(activity('CloudColumnCount').output.firstRow.OnPremColumnCount),
'. Schema/Table: ',
string(item().SchemaTableName)
)There is one detail to check carefully in your CloudColumnCount output.
In the screenshot you posted, CloudColumnCount appears to return:
firstRow -> OnPremColumnCountIf that is the actual output property name, then the expression must use OnPremColumnCount exactly as shown above.
If your cloud query is intended to return a property called CloudColumnCount, I would instead alias the result in that query as CloudColumnCount and then reference:
activity('CloudColumnCount').output.firstRow.CloudColumnCountI would also keep the Fail activity Error Code as a simple literal while testing, for example:
ColumnCountMismatch
Microsoft's Fail activity documentation requires both the error message and error code to resolve to strings.
The ErrorCodeNotString error therefore points to the Fail activity being unable to interpret one of those values correctly, rather than the Fail activity itself not working.
I would test the three dynamic values separately first:
string(activity('OnPremColumnCount').output.firstRow.OnPremColumnCount)
string(activity('CloudColumnCount').output.firstRow.OnPremColumnCount)
string(item().SchemaTableName)Once each one resolves successfully on its own, combine them with concat.
The main correction I would make first is replacing the reference to LookupGetTableList.output.SchemaTableName with item().SchemaTableName because you are already inside the ForEach iteration.
AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.