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
Replies
7 replies
Subscribers
7 subscribers
Views
2562 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
I have an XML response that returns a text data type however, the CDT in which I
karlaw
over 11 years ago
I have an XML response that returns a text data type however, the CDT in which I need to save the response values requires this field be an integer. How would I go about converting this value from text to integer?
XML Response value is text data type: AvailableBalance
if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()") )
Need to convert this specific field to integer in multiple PV array....
OriginalPostID-60769
OriginalPostID-60769
Discussion posts and replies are publicly visible
0
Owen Parrish
Appian Employee
over 11 years ago
tointeger()
forum.appian.com/.../Mathematical_Functions
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 11 years ago
I tried that in multiple places...it doesn't work.
These are where I tried them:
tointeger(if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()") ))
if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", tointeger(xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()") ))
if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/tointeger()") )
if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text(tointeger())") )
Where does the tointeger go?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Abhishek Shadangi
Appian Employee
over 11 years ago
Wherever makes sense, Appian also does the implicit data type conversion when saving expression values to the ACPs or the PVs. So, in addition to what Owen mentioned, you can also simply assign an expression with Text output to a PV of type Number (Integer) -- if the text can't be converted to a number, Appian will simply save a NULL value.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 11 years ago
I would expect both the first and second things you pasted to work. Depending on what "it doesn't work" means, there are different ways to debug.
I would start with confirming the actual type of the result of your expression. You can use the typename() and runtimetypeof() expressions for that. typename(runtimetypeof(<your whole expression>)) will tell you if you're actually getting an integer back or a string.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 11 years ago
Some clarification, after testing further this sytax does convert the value to integer...
tointeger(if( (xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()")) = "", "", xpathsnippet(pv!accountResponseBody_Txt, "//*[local-name(.)='AccountNumber']/text()") ))
The only problem remaining is that it only converts the first value in the pv array. There are several account number values in the XML response.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Owen Parrish
Appian Employee
over 11 years ago
You should be able to use apply() like =apply(fn!tointeger,<if xpath here>) Or like Abishek mentioned try just saving into a List of Number (Integer) pv.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
karlaw
over 11 years ago
When values that exceed the Number(Integer) range are passed through a user interface, the excessive value is changed.
?In most cases, this is changed to a null value
I have solved my problem. I must convert to a string. Thanks everyone for providing me with direction!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel