I currently have data being pushed into a CDT in the following format:
Questions_CDT
{
QuestionID: 1,
AnswerIDs: {1,2,3}
},
QuestionID: 2,
AnswerIDs: {3}
}
And I need it to format to:
AnswerID: 1
AnswerID: 2
AnswerID: 3
What would be the best way to accomplish this? I've tried nested a!foreach loops but to no avail. Any suggestions?
Discussion posts and replies are publicly visible
Assuming QuestionID is always a single value, this will do the trick:
= load( local!input: { { QuestionID: 1, AnswerIDs: {1, 2, 3} }, { QuestionID: 2, AnswerIDs: {3} } }, a!flatten( a!foreach( items: local!input, expression: with( local!qID: fv!item, a!foreach( items: local!qID.AnswerIDs, expression: { QuestionID: local!qID.QuestionID, AnswerID: fv!item } ) ) ) ))