Search code examples
alfrescoalfresco-sharealfresco-webscripts

people method is not working in pickerchildren.get.js Alfresco Community


Using alfresco community 5.0.d.

I am suddenly getting below error for people methods in pickerchildren.get.js file.

Can't find method org.alfresco.repo.jscript.People.getContainerGroups(org.mozilla.javascript.Undefined). (classpath*:alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js#366)

Error in console:

{
"status": {
"code": 500,
"name": "Internal Error",
"description": "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message": "Can't find method org.alfresco.repo.jscript.People.getContainerGroups(org.mozilla.javascript.Undefined). (classpath*:alfresco/templates/webscripts/org/alfresco/repository/forms/pickerchildren.get.js#366)",
"exception": "",
"callstack": [],
"server": "Community v5.0.0 (d r99759-b2) schema 8,022",
"time": "Mar 21, 2017 5:52:17 PM"
}

Where else in other part of the file people methods are working fine.

Below is code that I had added:

if (people.isAdmin(person)) {
    for each(var personRef in personRefs)
    {
        personObj = createPersonResult(search.findNode(personRef));
        // add to results
        results.push({
            item: personObj,
            selectable: true
        });
    }
    return;
}

It was working fine earlier but suddenly broke down.

Also person is coming as undefined.

Any idea is apprepicated. Thanks!


Solution

  • You can see from the error message that JavaScript is looking for a method getContainerGroups that accepts an undefined object.

    Based on that, I suspect personObj is null. You should add a guard against adding null items to the results array and see if that helps.