Is the Process Instance Key available as variable in the process instance?

Hello Everyone,
This is the follow-up question on “this”. This was not solved last time. Do we have this variable available now?

My use case is that I call one REST API by passing some data and storing it in DB. I am thinking of storing it against the processIntanceKey in DB so that it can be backtracked in OPERATE.

Or is there any other way to backtrack what I have in DB against what I see in OPERATE? I know checking each process instance is one way but that’s very lengthy.

How to do it if I want to check the flow/orchestration of one of the customer’s data?

Regards,
Jaikrat

The underlying Gibhub Issues for that thread are still open, so I would venture a guess that it’s not yet available.

Workaround:
When you’re starting your process, pass a business key variable to the process. Pass that to your REST API. The variable will be available in Operate to cross-reference with.

Alternatively: Create the Service Worker as described in the thread, populating a “ProcessID” variable which contains the process ID (as described in the thread you linked to). Put this service worker as the first step after the start step. Now you have the process ID as a variable.

Thanks @GotnOGuts for your reply … I was exploring the same at the same time and found it.

@Component
public class FetchProcessIntanceKey {

    @ZeebeWorker(type = "fetchProcessInstanceKey", autoComplete = true)
    public Map<String, String> serve(JobClient client, final ActivatedJob job) {
        System.out.println("+++++++++fetchProcessInstanceKey ++++++++++++");

        Map<String, String> map = new HashMap<>();
        map.put("processInstanceKey", String.valueOf(job.getProcessInstanceKey()));

        return map;
    }
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.