Updating multiple fields of CDT using for each & update()

HI Team,

I have a nested cdt. for example {id:1, employee:nested_cdt, contact:1234567890, age:21, year:1}, based on age field I'm updating the employee, contact, year using 3 different foreach. So can I do this in a single foreach using update(), I tried but it resulting in 3 different cdt's instead of one. Can anyone help or provide a better solution with a sample code?

Thanks in advance

 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    a!localVariables(
    local!a:{
    a!map(id:1, employee:"nested_cdt", contact:1234567890, age:21, year:1),
    a!map(id:2, employee:"nested_cd", contact:123456789, age:20, year:2),
    a!map(id:3, employee:"nested_c", contact:12345678, age:19, year:3)
    },
    local!b:if(local!a.age=21,
    {
    a!forEach(
    items:local!a,
    expression:a!update(fv!item,{"employee","age","contact","year"},{"Mounika",988,77777,0}),
    )
    },
    local!a
    ),
    local!b
    )

    Hi , Can you try this code by testing it in a rule. Hope this gives an answer to your question Slight smile

Reply
  • 0
    Certified Senior Developer

    a!localVariables(
    local!a:{
    a!map(id:1, employee:"nested_cdt", contact:1234567890, age:21, year:1),
    a!map(id:2, employee:"nested_cd", contact:123456789, age:20, year:2),
    a!map(id:3, employee:"nested_c", contact:12345678, age:19, year:3)
    },
    local!b:if(local!a.age=21,
    {
    a!forEach(
    items:local!a,
    expression:a!update(fv!item,{"employee","age","contact","year"},{"Mounika",988,77777,0}),
    )
    },
    local!a
    ),
    local!b
    )

    Hi , Can you try this code by testing it in a rule. Hope this gives an answer to your question Slight smile

Children
No Data