AnsweredAssumed Answered

ReferenceError: search is not defined - Alfresco community 5.2

Question asked by anuradha@1994 on Feb 2, 2019
Latest reply on Feb 2, 2019 by vidhipanchal

Hi,

I have created a dashlet to show all active workflows using workflow-instance & task-instance APIs. Its working perfectly. But, now what i need to do is, displaying that current task assignee username for every workflow. In task instance API, it returns only noderef as bpm_assignee.

ex: - bpm_assignee = workspace://SpacesStore/68e35102-a506-46b0-be48-4f8dc1c0e8bb

I need to get the username to my dashlet using this nodref.

My code is given below.

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

<script type="text/javascript">
function myFunction() {
$.ajax({
type: 'GET',
url: 'http://127.0.0.1:9090/alfresco/s/api/workflow-instances',
data: { get_param: 'value' },
dataType: 'json',
success: function (data) {
console.log(data);
console.log(data.data[0].description);
for (var i = 0; i < data.data.length; i++) {
if (data.data[i].isActive == true) {
$('#records_table').append(
'<tr>' +
'<td>' + data.data[i].message + '</td>' +
'<td>' + data.data[i].initiator.firstName + ' ' + data.data[i].initiator.lastName + '</td>' +
'<td>' + data.data[i].startDate + '</td>' +
'<td><a class="btn btn-info" href="http://127.0.0.1:9090/share/page/workflow-details?workflowId=' + data.data[i].id + '&referrer=workflows&myWorkflowsLinkBack=true" style="text-decoration: none;" target="_blank">Show Workflows</a></td>' +
'</tr>'

);
}

$.ajax({
type: 'GET',
url: 'http://127.0.0.1:9090/alfresco/s/api/workflow-instances/' + data.data[i].id + '?includeTasks=includeTasks?',
data: { get_param: 'value' },
dataType: 'json',
success: function (data) {
// console.log(data);
// console.log(data.data.startTaskInstanceId);
$.ajax({
type: 'GET',
url: 'http://127.0.0.1:9090/alfresco/s/api/task-instances/' + data.data.startTaskInstanceId,
data: { get_param: 'value' },
dataType: 'json',
success: function (response) {
console.log(response.data);
console.log(response.data.properties.bpm_assignee);

var foundNode = search.findNode(response.data.properties.bpm_assignee);
console.log("xxxxxxx"+ foundNode);

}
});
}
});
}
}
});
}
</script>

</head>

<body onload="myFunction()">

<table id="records_table" border="1">
<tr style="padding: 5px">
<th>Name of the letter</th>
<th>Current Asignee</th>
<th>Date of receipt</th>
<th>View history</th>
</tr>

</table>

</body>
</html>

In line 81 of above code i tried to search using findNode() method & it gives me following error.

ReferenceError: search is not defined

Please help me to find out a solution

Thanks.

Outcomes