Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cancelar(id, usuario) {
- var settings = {
- "url": "/api/public/2.0/workflows/cancelInstance",
- "method": "POST",
- "timeout": 0,
- "async": false,
- "headers": {
- "Content-Type": "application/json"
- },
- "data": JSON.stringify({ "processInstanceId": id, "cancelText": "Cancelado por API", "replacedId": usuario }),
- };
- $.ajax(settings).done(function (response) {
- console.log(response.content);
- return response.content;
- });
- }
- function consultar(usuario) {
- var settings = {
- "url": "/ecm/api/rest/ecm/centralTasks/getTasks/requests/" + usuario + "?rows=50&page=1",
- //"url": "/ecm/api/rest/ecm/centralTasks/getTasks/manager/" + usuario + "?rows=100&page=1",
- "method": "GET",
- "async": false,
- "timeout": 0,
- "headers": {
- "Content-Type": "application/json"
- },
- };
- var retorno = $.ajax(settings).done(function (response) {
- return response;
- });
- return retorno;
- }
- function repeticao(usuario) {
- var retornoCons = consultar(usuario);
- for (var index = 0; index < retornoCons.responseJSON.invdata.length; index++) {
- var element = retornoCons.responseJSON.invdata[index];
- console.log(element.processInstanceId);
- cancelar(element.processInstanceId, usuario);
- console.log(index == parseInt(retornoCons.responseJSON.invdata.length - 1))
- if (index == parseInt(retornoCons.responseJSON.invdata.length - 1)) {
- console.clear();
- console.log("Acabou");
- setTimeout(() => {
- start(usuario)
- }, 500);
- return "Acabou";
- }
- }
- }
- function start(params) {
- return repeticao(params);
- }
- start("academy.aluno");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement