GetLastDocument from a Archived Process

I need to take the last version of a document in a archived process.

I used the function apiAccessor.getProcessAPI().getArchivedProcessDocument(idDocument) but it brings to me the first document I inserted instead the last document.

For a instance process I use the function apiAccessor.getProcessAPI().getLastDocument(processInstanceId, variableName) and it works.

How can I get the same behaviour for a archived process?