Ao tentar usar o WCMAPI em evento global beforedocumentviewer
recebo o erro WCMAPI is not defined
function beforeDocumentViewer(){
//Informações do documento
var doc = getValue("WKDocument");
//var versao= getValue("WKNumVersion");
log.info("INFODEV beforedocumentviewer "+ doc.documentId);
try {
var c1 = DatasetFactory.createConstraint( "idarquivo", doc.documentId, doc.documentId, ConstraintType.MUST);
var constraints = new Array(c1);
var ds = DatasetFactory.getDataset("ds_leitura_obrigatoria", null, constraints, null);
}catch (e) {
log.error("Erro ao tentar atualizar a leitura do documento : " + e.message);
}
log.info("INFODEV beforedocumentviewer "+ ds.length);
ds.values.forEach(function(item, index){
dados = '[{"name": "leitura","value": "true"}]';
WCMAPI.Create({
url : "/ecm/api/rest/ecm/cardView/editCard/"+this.documentid+"/"+this.version,
method : "POST",
contentType: "application/json",
dataType: "json",
data : dados,
success : function(data) {
log.info("*****sucesso*****");
},
error : function(data, errorThrown, status) {
log.info("*****erro***** " + status);
}
});
});
}