cancel
Showing results for 
Search instead for 
Did you mean: 

ReferenceError: search is not defined - Alfresco community 5.2

anuradha1
Star Contributor
Star Contributor

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.

4 REPLIES 4

sanjaybandhniya
Elite Collaborator
Elite Collaborator

Hi,

You are performing search operation in share side where search.findNode()  is root object of repository not share.

Search API | Alfresco Documentation 

FYI,My Tasks dashlet is available which is giving same type of rersult.You can take the reference of that dashlet.

Thanks,

Sanjay

Thanks for the reply. Is there any other way to do this? I need to show current assignee for workflows in the dashlet. Plz help me

Thank you.

Hi,

If any task is assigned to any user, that user will become the owner of that task.

So using owner property you can get the user name of current assignee. 

Thanks,

Contcentric

Regards,
Vidhi

If you are using any script file and getting "Uncaught ReferenceError: x is not defined " which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.

To solve this error: Load your library at the beginning of all your scripts.

There can be multiple other reasons for this issue:

  • Conflict with Other Libraries
  • Path to your library included is not correct
  • Llibrary file is corrupted
  • Working offline (when you use CDN)