Best approach to consolidate record

Hi,

I’m trying to figure the best approach to consolidate data. Okay, I have a document list that looks something like below:

orderList
orderList[0]
field1 = 1
field2 = 3
refnum = 100
orderList[1]
field1 = 2
field2 = 5
refnum = 200
orderList[2]
field1 = 3
field2 = 4
refnum = 200

Each refnum should be unique. The above list would consolidate to:

orderList[0]
field1 = 1
field2 = 3
refnum = 100
orderList[1]
field1 = 5
field2 = 9
refnum = 200

Nevermind. Disregard this post.

I’ve found a solution. Basically, loop through the list and check to see if the refnum equal the last refnum. If so, map field1 and field2. If it doesn’t, then appendToDocumentList. Then loop through the the list again and apply the same check and them add field1 and field2 to the list.

If anyone has any input, I would greatly appreciated. The solution that I came up with doesn’t work 100%. Wondering if this could be accomplish through flow service or writing custom java service.

You should be able to do this using FLOW.

Can you describe the scenarios where your service does not work?

I’ve done it all in flow. I believe I have it resolved this time. I had to have a placeholder for the first data and then added some more logic to see which $iteration I’m on and if the last id equals the current id and such. I think I could create the service a bit better but what I’ve done thus far will work.