Skip to Content

How to store an ArrayList in SCP properties ?

Nov 28, 2017 at 07:10 PM


avatar image

Hey All,

I am developing an interface connecting EC with OnBoarding.

We are trying to generate multiple EmpIds using odata api - generateNextPersonId function, store them in an Array List and update multiple employees on the OnBoarding side.

Now I have generated the Ids and am able to store it in an ArrayList using Groovy scripting. Now I want to store that in the properties section so that I can access it later on.

How will I be able to do that?

I tried creating a global variable in properties section and store it. Didn't work. I can create Global variable, Local variables, Constant, Expression, Property, Header, XPath. It's weird that I cannot set the type for anything else except XPath. The Type field in the properties section gets greyed out when I select global variable. I though I could set the type as java.Util.ArrayList.

Any input will be highly appreciated.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sriprasad Shivaram Bhat
Nov 29, 2017 at 05:18 AM

Hello Kriba,

You can set the property containing ArrayList in Script itself


import java.util.HashMap;

def Message processData(Message message) {
    def body = message.getBody();
    List<String> list = new ArrayList<String>();

    def map = message.getHeaders();
    map = message.getProperties();
    message.setProperty("P_ArrayData", list);
    return message;

Write Variable:

Content Modifier to retrieve the value stored( just for testing purpose ):

Unfortunately its not possible retrieve individual elements of ArrayList written as Property( In earlier steps ) inside Content Modifier,you have to write a script again to get the elements one by one.But you can retrieve complete list of elements stored in one shot ( as shown in Content modifier by setting the value of variable to Property and access it later.)

Hope it helps.


Sriprasad Shivaram Bhat

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Worked like a charm! Thank you. I have written another csript to loop the Array and get the elements one by one.