# Get Execution variables of a DeadLetter Job

**URL:** <https://forum.flowable.org/t/get-execution-variables-of-a-deadletter-job/10223>\
**Category:** Flowable Engine\
**Created:** [February 14, 2023, 11:39am UTC](https://forum.flowable.org/t/get-execution-variables-of-a-deadletter-job/10223 "2023-02-14T11:39:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjcantero](https://avatars.discourse-cdn.com/v4/letter/c/3be4f8/32.png) [@cjcantero](https://forum.flowable.org/u/cjcantero)\
**Post date:** [February 14, 2023, 11:39am UTC](https://forum.flowable.org/t/get-execution-variables-of-a-deadletter-job/10223/1 "2023-02-14T11:39:09Z")

</div>

Hello,

We have a BPMN that includes an asynchronous ServiceTask (expression type).  
When the Service Task fails (after the retries), the job goes to the Deadletter and we can see the exception stack trace (“error while evaluation expression: ${myService.doSomething(execution.getVariables)}”).

¿Is there any way to get the execution variables used in the ServiceTask expression call?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![cjcantero](https://avatars.discourse-cdn.com/v4/letter/c/3be4f8/32.png) [@cjcantero](https://forum.flowable.org/u/cjcantero)\
**Post date:** [February 15, 2023, 7:40am UTC](https://forum.flowable.org/t/get-execution-variables-of-a-deadletter-job/10223/2 "2023-02-15T07:40:00Z")

</div>

Hello,

We have found a way to do this:

```auto
Job job = managementService.createDeadLetterJobQuery().jobId(id).singleResult();
	
if (job != null) {
	
	Execution jobExecution = runtimeService.createExecutionQuery()
		.executionId(job.getExecutionId())
		.processInstanceId(job.getProcessInstanceId())
		.list().stream()
			//we filter the list because we can't use activityId filter in query because that filter adds the execution alive condition)
			.filter( execution -> job.getElementId().equals(execution.getActivityId()) )
			.findFirst()
			.orElse(null);
	
	if (jobExecution != null) {
		//Lazy loading of variables. We need executing inside a CommandContext
		Map<String, Object> data = managementService.executeCommand(new Command<Map<String,Object>>() {
	
			@Override
			public Map<String,Object> execute(CommandContext commandContext) {
				
				return ((ExecutionEntity)jobExecution).getVariables();
	
			}
		});
	
	}
}

```

We don’t know if this is the best solution, but it works.

Thanks
