Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jan 10, 2017 at 04:25 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 11, 2017 at 10:24 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • May 09 at 11:53 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 09 at 11:53 PM

    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

    Add comment
    10|10000 characters needed characters exceeded