Hi guys,
I am writing the below code to split the string(separated by comma) into a list array.
I am giving multiple values to "source value" in content modifier.
Code:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.util.regex.*;
import groovy.xml.*;
def Message processData(Message message) {
def headers = message.getHeaders();
def rows;
def properties = message.getProperties();
def credentials = properties.get("UserList");
List<String> myList = Arrays.asList(credentials.split(","));
for(i=0;i < myList.size();i++)
{
rows = rows + (myList[i]+"\n");
}
// rows = rows.replace("null","");
message.setBody(rows)
return message;
}
But when I run this, I was able to get the below output.
Output:myoutput.png
I am getting a null at the beginning, I can simply replace it. I also tries to assign null value to my variable"rows". But still I am getting the same output. I want to know what is wrong with my groovy code.
Thank you!
Request clarification before answering.
Hello Veena,
Since you already created List, you can check and remove null values first, then continue with your logic.
list.removeAll([null])
Best regards,
Akmal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 5 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.