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