update CDT values in loop

Certified Associate Developer

I am new to Appian and I need to write a rule that takes an array of CDT objects; updates all of their "id" and "loanId" values to null; and returns them.

I have been trying to use a foreach loop as follows but the data won't change. what am I doing wrong?

a!localVariables(
  local!assestsLiabilitiesDetails: ri!assestsLiabilitiesDetails,
  
  expression:
  a!forEach(
    items: local!assestsLiabilitiesDetails,
    expression: {
      fv!item: a!update(fv!item, "id", null('type!{http://www.appian.com/ae/types/2009}Integer')),
      fv!item: a!update(fv!item, "loanId", null('type!{http://www.appian.com/ae/types/2009}Integer')),
    }
  ),
  
  a!save(target: ri!assestsLiabilitiesDetails, local!assestsLiabilitiesDetails)

)

Thank you in advance for the help!

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Hi, I hope the below example helps.

    a!localVariables(
      local!inputs: {
        { id: 1, loanid: 6789, acctNum: "ACC1567" },
        { id: 2, loanId: 7823, acctNum: "ACC83049" }
      },
      local!idUpdatedToNull: a!forEach(
        items: local!inputs,
        expression: a!update(fv!item, "id", null())
      ),
      local!loanIdUpdatedToNull: a!forEach(
        items: local!idUpdatedToNull,
        expression: a!update(fv!item, "loanId", null())
      ),
      local!loanIdUpdatedToNull
    )

Reply
  • +1
    Certified Lead Developer

    Hi, I hope the below example helps.

    a!localVariables(
      local!inputs: {
        { id: 1, loanid: 6789, acctNum: "ACC1567" },
        { id: 2, loanId: 7823, acctNum: "ACC83049" }
      },
      local!idUpdatedToNull: a!forEach(
        items: local!inputs,
        expression: a!update(fv!item, "id", null())
      ),
      local!loanIdUpdatedToNull: a!forEach(
        items: local!idUpdatedToNull,
        expression: a!update(fv!item, "loanId", null())
      ),
      local!loanIdUpdatedToNull
    )

Children