I am getting a String in my work flow. which is ideally one or 2 lines of string value.
Eg: StringValue = “Error: The program failed to execute because of the change in Schema”.
I have list of Error Messages in the “constant” tab of Config File. 7 different Error Messages.
I need to check whether the above StringValue which I got is part of the Error Messages list in the Config file.If the String matches with any of the Error Messages, Then I need to certain action. Likewise, For each Error Message, I need to perform separate action.
How to approach this? I tried using Switch/Flow Switch. But I had to use “.Contains” function in the Experession and not “.Equals” since the Error Messages are more than 1 line. If I use “.Contains” in the Switch, It results in a Boolean. I could get only 2 results (True/False) out of one Switch. But I have 7 different Error scenarios in this case.
Kindly help me out with a solution.
Thanks in advance
Create a list or array of error messages you have say listvar
Now in if condition expression use listvar.Any(function(x) x.contains("errormessage))
On then side use switch activity with listvar.IndexOf(listvar.Where(function(x) x.contains("errormessage"))(0)) this will give the index of the error message
In the cases use the number 0,1,2,3,4 as case numbers and depending on the index of error message the switch will change
Hi @besakkiappan46 - You can use switch activity with .equals condition
I assume since the error messages is coming from a config variable, those must be saved in a config variable. Within the switch activity use below condition
The code is largely working. but I face an issue while checking the “IF” condition.
Below is the result I got:
ErrorText.Trim
“Canvas schema version has changed from last extract. Previous: V2.0.1, Current: V1.0.9”
ListOfErrors
List(7) { “Canvas schema version has changed from last extract. Previous:”, “Canvas extract must be complete and from today. Current extract was last updated at:”, “One or more new source table schema different from a target table schema.”, "rows failed to load exceeding limit of ", “One or more source table row counts different from a target table row count.”, “One or more source table columns not different (not encrypted) from a target table column.”, “file does not exist, but table data is required, aborting load” }
The ErrorText which I got matches with the 1st item in the List. Though it is not an exact match, Until the text “Previous:” , It does Match.
But It still goes to the “Else” part of the condition.