AnsweredAssumed Answered

Combining Records and Creating array through that

Question asked by amitkumar.chouksey on Aug 14, 2017
Latest reply on Jan 4, 2018 by mmorthala189353

Hi,

 

I have a scenario as below:

 

1. I have reocrds with simple XML profile as following -

 

<Account>

<Id>1</Id>
<ContactId>0011</ContactId>
<AccountId>0022</AccountId>
</Account>

 

<Account>
<Id>1</Id>
<ContactId>0012</ContactId>
<AccountId>0023</AccountId>
</Account>

 

<Account>
<Id>2</Id>
<ContactId>0021</ContactId>
<AccountId>0032</AccountId>
</Account>

 

Requirement is to combine these documents id IDs is same in XML profile, however after combining my motto is to create a new profile as following :

 

Since ID is same here the output should look like this :

 

<Account>
<Id>1</Id>
<ContactId>0011</ContactId>

<ContactId>0012</ContactId>
<AccountId>0022</AccountId>

<AccountId>0023</AccountId>
</Account>

 

Second record should be as it was :

 

<Account>
<Id>2</Id>
<ContactId>0021</ContactId>
<AccountId>0032</AccountId>
</Account>

 

And going forward I need to map this to a json profile which should look like some like following

 

Record 1 -

 

{
"requestContext": {
"timezone": "420"
},

"id": [{
"ContactId": "0011",
"AccountId": "0022"
}, {
"ContactId": "0012",
"AccountId": "0023"
}

]
}

 

Record 2 -

 

 

{
"requestContext": {
"timezone": "420"
},

"id": [{
"ContactId": "0021",
"AccountId": "0032"
}]
}

 

Please suggest.

 

Many Thanks in Advance

Outcomes