cancel
Showing results for 
Search instead for 
Did you mean: 

How to store the data in Hash map by using groovy script?

former_member305454
Participant
0 Kudos

We have a requirement to fetch the data from SuccessFactor and store it into hashmap.

Accepted Solutions (0)

Answers (4)

Answers (4)

adityawsharma
Explorer
0 Kudos

Hello Namesake :),

Note sure whether this query was closed, if not, please refer the below snippet to make use of the HashMaps in CPI using Groovy scripting.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
HashMap myHashMap = new HashMap<String,String>();
def pIdExternal = person_id_external; // this is the value you have received from parsing the incoming XML using Groovy Scripting.
myHashMap.put("MyKey_thisCanBePersonIdExternal","MyValue_thisCanBeAnyValueYouWantToStoreAgainstPIDExternal");

message.setProperty("myHashMap", myHashMap); return message; }

This hashmap and subsequent updates can be accessed via property call from any of the following nodes, even in branches with Parallel / Sequential multicasts.


Thanks,

Aditya

adityawsharma
Explorer
0 Kudos

Hello Namesake :),

Note sure whether this query was closed, if not, please refer the below snippet to make use of the HashMaps in CPI using Groovy scripting.

import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
HashMap myHashMap = new HashMap<String,String>();
def pIdExternal = person_id_external; // this is the value you have received from parsing the incoming XML using Groovy Scripting.
myHashMap.put("MyKey_thisCanBePersonIdExternal","MyValue_thisCanBeAnyValueYouWantToStoreAgainstPIDExternal");

message.setProperty("myHashMap", myHashMap); return message; }

This hashmap and subsequent updates can be accessed via property call from any of the following nodes, even in branches with Parallel / Sequential multicasts.


Thanks,

Aditya

former_member305454
Participant
0 Kudos

Hi Sriprasad,

Thanks for Reply.

I am fetching the compound employee data from SuccessFactor and want to store the person_id_external into HashMap ArrayList .

Actually for validation purpose i am storing value into HashMap.

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Aditya,

Could you please elaborate more on your requirement .Do you want to store the list of values coming in message mapping queue in ArrayList in message mapping or something else?

Regards,

Sriprasad Shivaram Bhat