The following code is an example script written in the Groovy language within a Script Task.

It has been shown that many different types of data are produced with the resultMap variable and how these data are transferred to other processes as JSON.

The JSON display of the resultMap value is important in terms of giving an idea of how to use the data added with the script in the next step of the process.

import groovy.json.JsonSlurper
import groovy.util.XmlSlurper
import java.time.LocalDateTime
import java.time.LocalDate
 
resultMap.put("textSample","text value");

def json='{ "name": "John", "surname":"Doe"}'
def object = new JsonSlurper().parseText(json)
resultMap.put("jsonObjectSample",object);

resultMap.put("jsonTextSample",'{ "name": "John", "surname":"Doe"}');

def xml='''<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 		xmlns:v1="http://schema.apinizer.com/Yardimci/EPosta/v1">
    <soapenv:Header/>
    <soapenv:Body>
    </soapenv:Body>
</soapenv:Envelope>''';

def Envelope = new XmlSlurper().parseText(xml);

resultMap.put("xmlObjectSample", object);
resultMap.put("xmlTextSample", xml);

resultMap.put("numberSample1", 100);
resultMap.put("numberSample2", 99.99);

// takes the date encoded as milliseconds since midnight, January 1, 1970 UTC
def date1 = new Date(System.currentTimeMillis())
resultMap.put("dateSample1", date1);

// create from an existing Calendar object
def date2 = new GregorianCalendar(2021, Calendar.APRIL, 3, 1, 23, 45).time
resultMap.put("dateSample2", date2);

LocalDate localDate=LocalDate.now()
resultMap.put("localDate", localDate);

LocalDateTime localDateTime = LocalDateTime.now();
resultMap.put("localDateTime", localDateTime);
GROOVY

When this script runs, the resultMap JSON state will be like the sample data below.

[
	{
		"dateSample1": "2021-11-25T13:05:46.969+0000",
		"dateSample2": "2021-04-02T22:23:45.000+0000",
		"jsonObjectSample": {
			"name": "John",
			"surname": "Doe"
		},
		"jsonTextSample": "{ \"name\": \"John\", \"surname\":\"Doe\"}",
		"localDate": "2021-11-25",
		"localDateTime": "2021-11-25T16:05:46.983",
		"numberSample1": 100,
		"numberSample2": 99.99,
		"textSample": "text value",
		"xmlObjectSample": {
			"name": "John",
			"surname": "Doe"
		},
		"xmlTextSample": "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v1=\"http://schema.apinizer.com/Yardimci/EPosta/v1\">\n    <soapenv:Header/>\n    <soapenv:Body>\n    </soapenv:Body>\n</soapenv:Envelope>"
	}
]
TEXT