Skip to main content
August 8, 2024
Solved

casting issue

  • August 8, 2024
  • 5 replies
  • 0 views

I am an trying to verify column type of each row in excel sheet against an array having type numbers

TESTCASES:

test1:{"1","abc"}  passes 

test2:{"abc","abc"} also passes which should actually fail .Please let me know where it went wrong

code used , 

local!error:a!forEach(
items:index(ri!data,"values"),
expression:{
a!localVariables(
local!rowNumber:fv!index,
a!forEach(
items: fv!item,
expression:{
if(a!isNotNullOrEmpty(fv!item),
if(typeof(cast(local!types[fv!index],fv!item))=local!types[fv!index],{},"Type does not match at Row"&local!rowNumber&" and column"& fv!index),
{}
)
}
)
)

}

),

    Best answer by kowsalyav7826

    I changed my logic to regex , test cases works fine for Integer, can you help me who to write regex for date

    5 replies

    stefanhelzle0001
    August 8, 2024
    [quote userid="248371" url="~/discussions/f/new-to-appian/37251/casting-issue"]typeof(cast(local!types[fv!index],fv!item))=local!types[fv!index][/quote]

    This will always match as you cast a value to the type you compare to.

    At least this is what I see this code snippet doing .....

    August 8, 2024

    is there any alternate way to do this. 

    stefanhelzle0001
    August 8, 2024

    Sure. Do NOT cast the value.

    typeof(fv!item)=local!types[fv!index]

    But keep in mind that I am not sure I fully understand what you are doing.