Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables returned from HTTP task are no longer available in parent scope #32

Open
Klaus-Nji-sp opened this issue Dec 6, 2019 · 2 comments

Comments

@Klaus-Nji-sp
Copy link

Klaus-Nji-sp commented Dec 6, 2019

In the previous release of this task, the following variables were returned:

  • statusCode
  • body

Without defining any output mapping, it was possible to reference these variables in downstream paths of a workflow. For example, I used the statusCode in one branch of the exclusive gateway as follows:

statusCode == 200 && someOtherProperty != null

This worked.

With the current release, statusCode is no longer available in scope of the parent process. Meaning this variable can no longer be used in downstream steps or conditions unless you define an output mapping on the http task as follows:

Output Mapping:
source: statusCode
target: statusCode

According to the literature, if output mappings are not defined, variables returned from a task or process will be merged into the parent variable scope.

Please refer to the BPMN model and rename from .txt to .bpmn.

Associated code to run the workflow is as follows:

DeploymentEvent deployment =
				client.newDeployCommand().addResourceFromClasspath("simple-http-process.txt").send().join()

        	OffsetDateTime now = OffsetDateTime.now();

		final Map<String, Object> post = new HashMap<>();
		post.put("userid", "1");
		post.put("title", now.toString() +  ": it's all about clean code");
		post.put("body",  now.toString() + " : read some good books on clean code");

		// FOR REST, you specify payload as parameter like this.  In other words there must be context variable called "body"
		final Map<String, Object> payload = new HashMap<>();
		payload.put("postToCreate", post);

		WorkflowInstanceEvent wfInstance =	client
						.newCreateInstanceCommand()
						.bpmnProcessId("simple-http-process")
						.latestVersion()
						.variables(payload)
						.send()
						.join();

simple-http-process.txt

@saig0
Copy link
Contributor

saig0 commented Dec 9, 2019

Hi @Klaus-Nji-sp,

I don't think that this behavior was changed in the latest release.

In your example, I see that the task has an output mapping to pass the body to a given variable. If one output mapping is defined then the default merging behavior is disabled and all variables have to be mapped explicitly. Otherwise, the variables are not merged.

Does this make sense for you?

@Klaus-Nji-sp
Copy link
Author

Klaus-Nji-sp commented Dec 9, 2019

If one output mapping is defined then the default merging behavior is disabled and all variables have to be mapped explicitly. Otherwise, the variables are not merged.

@saig0 , that does not sound quite accurate. Using the same example, I removed the mapping from body to postCreated and kept the mapping from statusCode to createPostStatusCode and there was partial mapping. The variable createPostStatusCode was available for use in conditional logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants