import ProcessMaker_Client.ApiClient;
import ProcessMaker_Client.ApiException;
import ProcessMaker_Model.Users;
import ProcessMaker_Api.UsersApi;
// A ProcessMaker Script written in Java must have a 'Script' class that implements 'BaseScript'.
// It must include a method named 'execute'. Results must be pushed to the 'output' map.
public class Script implements BaseScript {
Map<String, Object> data,
Map<String, Object> config,
Map<String, Object> output,
// Get a ProcessMaker Environment Variable, in this example TEST_VAR.
Map<String, String> env = System.getenv();
output.put("env-var", env.get("TEST_VAR"));
// Get a value from the config object.
// In this example, 'test' in the JSON config: {"test":"test config value"}
output.put("config-test", config.get("test"));
// Get a value from the data object.
// In this example, the user_id for the _request.
Map requestData = ((Map)data.get("_request"));
output.put("data-request-user-id", requestData.get("user_id"));
// Get the email address for user id 1 using the API/SDK.
UsersApi apiInstance = new UsersApi(api);
Users user = apiInstance.getUserById("1");
output.put("user-1-email", user.getEmail());
} catch (ApiException e) {