Skip to main content
November 9, 2023
Question

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

  • November 9, 2023
  • 3 replies
  • 0 views

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

[mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05] 

    3 replies

    stefanhelzle0001
    Brainy
    November 9, 2023

    We need to see your actual code to by able to give any hints.

    gopalk2865
    Participating Frequently
    November 9, 2023

    Can you please explain your use case little bit more? if you can share the code that will be really helpful too

    November 10, 2023

    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 [emoticon:c4563cd7d5574777a71c318021cbbcc8]