I am currently encountering a challenge with data retrieval from DAI, where the data is received as a string (e.g., “true,true”). This data needs to be passed to an API call in a non-string format (e.g., true,true). Given that the values can vary (e.g., “true,Approved,true”), directly using Boolean might not be feasible. I would appreciate any assistance in addressing this issue.
How do you enter the parameter string in DAI? Can you share a screenshot?
In case you have one string “Karsten,Wenzke,Keysight”. you need to split if by comma in your handler
on MyHandler varA
Split VarA by comma
put varA // should be a list now
Put item 1 of VarA
end
Here an example handler that should work for two parameter of a model action
on MyHandler varA, VarB
put varA
put varB
end myHandler
Params FinalizationText
put split(FinalizationText,",") into mylist
put number of items in mylist into itemscount
if itemscount = 0 then
put () into Reqdata
else
set icount =1
repeat itemscount times
insert item icount of mylist after Reqdata
add 1 to icount
end Repeat
end if
Not sure if your questions is solved or not.
Are you happy with your handler and it is working for you?
It takes the parameter string that by default is one text string as you have defined it.
I do not understand why you have the if statement.
Mylist is the same as reqdata. a list of n items
here is a handler that might do what you have in mind.
FinalreqData "true,abc,true" -- same as your DAI parameter
to FinalreqData FinalizationText
split FinalizationText by comma -- this turns the text into a list
put FinalizationText -- ["true","abc","true"]
put number of items in FinalizationText into itemscount -- equals the number of items in the list
put itemscount -- 3
-- by default each variable is treated as text and sensetalk determines the type internally when needed. The user does not need to care about it.
put !"[[item 1 of FinalizationText]]" -- puts the value true without quotes. you will see just true on the output
end FinalreqData