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
8406 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
johng373
over 9 years ago
Thanks for your responses. I think I am closer. I can now find the null values and replace them, however, the null values are getting replaced with a value from a different index of the CDT.
In my button a!save() function, I now have:
a!save(ri!BuyerSeller.feeAmount, apply(rule!ReplaceNulls,ri!BuyerSeller))
In my "rule!ReplaceNulls", I have:
if(isnull(ri!BuyerSeller.feeAmount),0,ri!BuyerSeller.feeAmount)
Data as it appears before executing the button which calls this code:
BuyerSeller[1].feeAmount: null
BuyerSeller[2].feeAmount: 44.00
Data as it appears after executing the button which calls the code:
BuyerSeller[1].feeAmount: 0
BuyerSeller[2].feeAmount: 0
So, this code is kind of working as it is replacing the null value at index 1, however, it should not replace the 44.00 value in index 2. Can you help point me in the right direction of how I can specify indices or if I even need to?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
johng373
over 9 years ago
Thanks for your responses. I think I am closer. I can now find the null values and replace them, however, the null values are getting replaced with a value from a different index of the CDT.
In my button a!save() function, I now have:
a!save(ri!BuyerSeller.feeAmount, apply(rule!ReplaceNulls,ri!BuyerSeller))
In my "rule!ReplaceNulls", I have:
if(isnull(ri!BuyerSeller.feeAmount),0,ri!BuyerSeller.feeAmount)
Data as it appears before executing the button which calls this code:
BuyerSeller[1].feeAmount: null
BuyerSeller[2].feeAmount: 44.00
Data as it appears after executing the button which calls the code:
BuyerSeller[1].feeAmount: 0
BuyerSeller[2].feeAmount: 0
So, this code is kind of working as it is replacing the null value at index 1, however, it should not replace the 44.00 value in index 2. Can you help point me in the right direction of how I can specify indices or if I even need to?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data