Solved as follow
Defined the following variable di UI Designer:
allTask …/API/bpm/task?p=0&c=1000 External API
that will return an array like the following:
[
{
“displayDescription”: “Il procedimento è in attesa che il responsabile lo visioni ed approvi il regolamento”,
“executedBy”: “0”,
“rootContainerId”: “1004”,
“assigned_date”: “2023-08-03 12:10:58.477”,
“displayName”: “Accettazione del Regolamento da parte del Responsabile”,
“executedBySubstitute”: “0”,
“dueDate”: “”,
“description”: “La richiesta è assegnata al responsabile che deve prendere visione del regolameno e procedere o meno all’accettazione dello stesso”,
“type”: “USER_TASK”,
“priority”: “normal”,
“actorId”: “106”,
“processId”: “6561950334030087816”,
“caseId”: “1004”,
“name”: “Accettazione Regolamento”,
“reached_state_date”: “2023-08-03 12:10:58.478”,
“rootCaseId”: “1004”,
“id”: “20039”,
“state”: “ready”,
“parentCaseId”: “1004”,
“last_update_date”: “2023-08-03 12:10:58.478”,
“assigned_id”: “214”
},
…
]
Define a variable existTaskForPID as Javascript expression that do this:
async function getCaseInfo(cid)
{
var r = null;
var x = await fetch(“…/API/bpm/case/” + cid + “/context”)
.then((response) => response.json())
.then((json) => r = json);
console.log(“>>>> getCaseInfo(cid: '”+cid+"') => “,r);
return r;
}
if ( $data.allTask && $data.allTask.length && (typeof $data.richieste_selected !== ‘undefined’) && ($data.richieste_selected !== null) && (typeof $data.richieste_selected.persistenceId !== ‘undefined’) )
{
return $data.allTask.every(
async function(e, i)
{
var caseDetails = await getCaseInfo(e.caseId);
var exist = ((caseDetails && caseDetails.richiestaBDM_ref && caseDetails.richiestaBDM_ref.storageId)?(caseDetails.richiestaBDM_ref.storageId == $data.richieste_selected.persistenceId):false);
console.log(”>>>> Case Info: ", i, exist);
return exist;
}
);
}
else
{
return false;
}
so if the JavaScript variable: existTaskForPID=false i can proceed with deletion of the BDM record.
This is my solution to the problem, in case it helps someone…
If you have a better solution let me know
Samuel