I am trying to loop through a CDT and replace any null values with 0.

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
  • I tried the following:
    a!save(ri!BuyerSeller.feeAmount,updateArray(ri!BuyerSeller.feeAmount,wherecontains(todecimal(null()), ri!BuyerSeller.feeAmount),0))

    and received the same result (All indexes get updated to 0). I should mention that this CDT has many more fields within it. I was only trying to update 1 field within the CDT at first just to learn how to loop through a CDT and update specific indexes. Still just trying to figure out how to update a specific index using a!save(). The reason I am using a!save() is because I want to update these null values when a user clicks the submit button.
Reply
  • I tried the following:
    a!save(ri!BuyerSeller.feeAmount,updateArray(ri!BuyerSeller.feeAmount,wherecontains(todecimal(null()), ri!BuyerSeller.feeAmount),0))

    and received the same result (All indexes get updated to 0). I should mention that this CDT has many more fields within it. I was only trying to update 1 field within the CDT at first just to learn how to loop through a CDT and update specific indexes. Still just trying to figure out how to update a specific index using a!save(). The reason I am using a!save() is because I want to update these null values when a user clicks the submit button.
Children
No Data