Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
+1
person also asked this
people also asked this
Replies
11 replies
Subscribers
8 subscribers
Views
12683 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Converting a string to an integer array
judym598
Certified Senior Developer
over 8 years ago
I have a form that captures user input to include multiple values via a checkbox field. The values are stored in a pv (integer array called pv!dataTypes_int). For example: (4;7;10), which are ids from another CDT used at a later point in the process to display data from the reference table. The integer array is then converted to a string and saved as part of a CDT (i.e., pv!newEula_cdt.dataType). In order to redisplay the values checked on that form, I have to convert the string of numbers to an integer but when I use the tointeger(pv!newEula_cdt.dataType) I get (4710). Is there a way to convert this string back to an integer and retain the semicolons?
OriginalPostID-232073
Discussion posts and replies are publicly visible
0
Colton Beck
over 8 years ago
Instead of using tostring() to convert to text, you could try touniformstring() which should maintain the array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judym598
Certified Senior Developer
over 8 years ago
The 'tostring(pv!dataTypes_int)' part works just fine. The semicolons are saved there - my problem is when I convert it back to an integer.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Colton Beck
over 8 years ago
It may appear that way, but tostring() does not preserve inputs as multiple.
To test, plug these into the expression editor to see the difference:
tointeger(tostring({1,2,3,4}))
tointeger(touniformstring({1,2,3,4}))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judym598
Certified Senior Developer
over 8 years ago
That works but it doesn't work when I replace the {1,2,3,4} with my pv which is (4;7;10). Create a rule input (i.e., dataType of type 'Text' and enter 4;7;10 as the test value) with the rule input =tointeger(touniformstring(ri!dataType)). When tested - the result is 4710 not 4;7;10
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
gaurava322
over 8 years ago
Hi Judy, try touniformstring(), coltonb is correct..
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Colton Beck
over 8 years ago
Interesting.
Would something like this work for you?:
tointeger(split("1;2;3",";"))
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judym598
Certified Senior Developer
over 8 years ago
Yes! That worked! Thank you!!!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Colton Beck
over 8 years ago
Happy I could help!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
Judy - out of interest, in your test was your rule input text, or text multiple?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
judym598
Certified Senior Developer
over 8 years ago
text - not text multiple
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>