BusinessKey didnt show in History API (both, Rest and Java), but shows in Cockpit

Hi!
I have some code that query history of process instances like this:

        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery()
            .startedAfter(cal.getTime())
            .finished()
            .processDefinitionKey("Aml_executor")
            .orderByProcessInstanceBusinessKey()
            .desc()
           .list();

And in this list BusinessKey of all my instances in null. I try to check it by REST API and


IN aml executor i set Business key by listner on start event like this:

String Businesskey =request.getRequestSource().getSourceTable().getName();
    ((ExecutionEntity)execution).setBusinessKey(Businesskey);

it is intresting that evrything was fine, when i use h2 DB. But today i switch to postgresql and get this.

Can somebody fugure out whats going on?

i check it like this on h2 db to and clear process:



When i run my process manually and set business key API return manual input, cockit show script result:


Look`s like thouse script is not legit :frowning:

And here the solution!

I wrapped my process, where i need BusinessKey, with process i populate BusinessKey truth