Skip to content

Instantly share code, notes, and snippets.

@doug1n
Last active May 22, 2021 01:02
Show Gist options
  • Save doug1n/320ba1b2f226f7240f8f71de0c2a6083 to your computer and use it in GitHub Desktop.
Save doug1n/320ba1b2f226f7240f8f71de0c2a6083 to your computer and use it in GitHub Desktop.
"Mover" aquivo utilizando apenas docAPI e fluigAPI
/*
* Clona um documento, salva em uma pasta especifica e deleta o documento clonado
* Retorna o código do documento clonado
*/
function moverDocumento(documentoId, versaoDocumento, pastaDestinoId) {
var phisicalFile = docAPI.copyDocumentToUploadArea(documentoId, versaoDocumento)[0];
var docDto = docAPI.newDocumentDto();
docDto.setDocumentId(0);
docDto.setDocumentTypeId("");
docDto.setDocumentDescription(phisicalFile);
docDto.setParentDocumentId(parseInt(pastaDestinoId));
var attachArray = new java.util.ArrayList();
var mainAttach = docAPI.newAttachment();
mainAttach.setFileName(phisicalFile);
mainAttach.setPrincipal(true);
mainAttach.setAttach(false);
attachArray.add(mainAttach);
var doc = docAPI.createDocument(docDto, attachArray, null, null, null);
fluigAPI.getDocumentService().deleteDocument(documentoId);
return doc.getDocumentId();
}
@BielPinto
Copy link

BielPinto commented May 22, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment