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
  • Your test code worked for me. I saw the null values get updated to 0 and the non null values stayed in tact. I am trying this on a Task which is currently running within a process model. One silly question I have is how would I get "toDecimal" to be a part of my feeAmount? The feeAmount field type is a Number (Decimal) but the values look like this:
    [ID=,
    requestID=8375,
    buyerProject=1234,
    buyerTask=123,
    totalDollarAmt=23,
    totalHours=0,
    sellerProject=,
    sellerTask=,
    feeAmount=],
    [ID=,
    requestID=8375,
    buyerProject=12345,
    buyerTask=1234,
    totalDollarAmt=,
    totalHours=,
    sellerProject=,
    sellerTask=,
    feeAmount=44]

    So, if I have the following code in my a!save():
    a!save(ri!BuyerSeller,updateArray(ri!BuyerSeller.feeAmount,wherecontains(todecimal(null()), todecimal(ri!BuyerSeller.feeAmount)),0))
    I now receive an error indicating: Invalid index: "Cannot index property 'buyerProject' of type Text into type Number (Decimal)." I must be missing something big here. :)
Reply
  • Your test code worked for me. I saw the null values get updated to 0 and the non null values stayed in tact. I am trying this on a Task which is currently running within a process model. One silly question I have is how would I get "toDecimal" to be a part of my feeAmount? The feeAmount field type is a Number (Decimal) but the values look like this:
    [ID=,
    requestID=8375,
    buyerProject=1234,
    buyerTask=123,
    totalDollarAmt=23,
    totalHours=0,
    sellerProject=,
    sellerTask=,
    feeAmount=],
    [ID=,
    requestID=8375,
    buyerProject=12345,
    buyerTask=1234,
    totalDollarAmt=,
    totalHours=,
    sellerProject=,
    sellerTask=,
    feeAmount=44]

    So, if I have the following code in my a!save():
    a!save(ri!BuyerSeller,updateArray(ri!BuyerSeller.feeAmount,wherecontains(todecimal(null()), todecimal(ri!BuyerSeller.feeAmount)),0))
    I now receive an error indicating: Invalid index: "Cannot index property 'buyerProject' of type Text into type Number (Decimal)." I must be missing something big here. :)
Children
No Data