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
18 replies
Subscribers
8 subscribers
Views
8421 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
I am trying to loop through a CDT and replace any null values with 0.
johng373
over 9 years ago
I am trying to loop through a CDT and replace any null values with 0.
To test this out, I added a button on my form and upon clicking the button I am executing:
a!save(ri!BuyerSeller, apply(rule!ReplaceNulls,ri!BuyerSeller)) /*ri!BuyerSeller is the CDT in which I want to loop through and replace nulls*/
My "rule!ReplaceNulls" is as follows (currently I am just trying to get 1 field to work in the CDT, but this will end up being 3 fields)
={
if(isnull(ri!BuyerSeller.feeAmount),0,ri!BuyerSeller.feeAmount)
}
I keep receiving an error about "Invalid index: Cannot index property "buyerProject" of type Text into type Number (Decimal)".
buyerProject is the first element of my CDT, but this is not one of the fields I care to parse through and check for nulls. How can I loop through a CDT and replace nulls values? Thanks
OriginalPostID-202277
OriginalPostID-202277
Discussion posts and replies are publicly visible
Parents
0
Jin Pheh
Certified Associate Developer
over 9 years ago
Interesting - I just tried another test with dummy objects and it updates only the nulls to zero as expected (See below).
Stupid question here but are you testing this in the interface editor or are you running a process model and clicking on the submit within a real task? Also, does the test code below work for you when you try it in a new rule?
------------
load(
local!test: {
{Id:1, feeAmount: toDecimal(1)},
{Id:2, feeAmount: toDecimal(2)},
{Id:3, feeAmount: toDecimal(null())},
{Id:4, feeAmount: toDecimal(12.31)},
{Id:5, feeAmount: toDecimal(null())},
{Id:6, feeAmount: toDecimal(null())}
},
updateArray(local!test.feeAmount, wherecontains(todecimal(null()), todecimal(local!test.feeAmount)), 0)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Jin Pheh
Certified Associate Developer
over 9 years ago
Interesting - I just tried another test with dummy objects and it updates only the nulls to zero as expected (See below).
Stupid question here but are you testing this in the interface editor or are you running a process model and clicking on the submit within a real task? Also, does the test code below work for you when you try it in a new rule?
------------
load(
local!test: {
{Id:1, feeAmount: toDecimal(1)},
{Id:2, feeAmount: toDecimal(2)},
{Id:3, feeAmount: toDecimal(null())},
{Id:4, feeAmount: toDecimal(12.31)},
{Id:5, feeAmount: toDecimal(null())},
{Id:6, feeAmount: toDecimal(null())}
},
updateArray(local!test.feeAmount, wherecontains(todecimal(null()), todecimal(local!test.feeAmount)), 0)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data