cancel
Showing results for 
Search instead for 
Did you mean: 

how to combine the message of the same employee.

WPGH_Christy
Explorer
0 Kudos

Dear exports,

I am using the CPI to get data from the SF.But I am trying to combine some message of the same employee.

Now I am getting the data of the entity "PerPhone",and it returned me the record like below, each person's each phone number is one record.And some employees may have two business phone numbers, and it will return two records to me.But I want to combine them like into a same record and split the phone number with the ",".Just like below.

original return phone number(assume the employee have two business phoneNumbers):


the format I hope it looks like:

{

"emp_id":"Test_Import",

"Business":

{ "phoneNumber1","phoneNumber2"},

.....

}

Any Suggestions will be appreciated!!

Regards,

Christy.

Accepted Solutions (0)

Answers (1)

Answers (1)

r_herrmann
Active Contributor
0 Kudos

Hi alltan_7099 ,

I would suggest to write a GroovyScript which parses and merges the nodes. Use the JSONSlurper to parse the JSON nodes: http://groovy-lang.org/json.html

The iterate via ...each{ node -> /* your merge logic */ } over all nodes. If you find a node with an "emp_id" which you already have seen, read the number, merge it to the already known node and delete the current node.

By the way - the target format should look like:

{
"emp_id":"Test_Import",
"Business": ["phoneNumber1","phoneNumber2"],
...
}

(With [ ] instead of { }, because arrays have to be declared with [].)

WPGH_Christy
Explorer
0 Kudos

Hi Raffael Hermann,

Thank you so much for your message,I will try it!

Regards,

Christy.