HiI was trying to add a user to a group using webscript.The files created areAddUserToGroup.get.desc.xml:
<webscript>
<shortname>AddUserToGroup</shortname>
<description>AddUserToGroup</description>
<url>/sample/AddUserToGroup</url>
<format default="html">argument</format>
<authentication>admin</authentication>
<transaction>required</transaction>
</webscript>
AddUserToGroup.get.js:
var user = people.getPerson("ggc");
var group = people.getGroup("Gerentes");
if (user == undefined)
{
status.code = 404;
status.message = "User not found";
status.redirect = true;
}
else if (group == undefined)
{
status.code = 404;
status.message = "Group not found";
status.redirect = true;
}
else
{
people.addAuthority(group,user);
}
AddUserToGroup.get.html.ftl:
<html>
<head>
<title>Groups</title>
</head>
<body>
User assigned to group
</body>
</html>
The code is very simple (It's just for testing) but it doesn't work.When i try it, it throwsThe Web Script /alfresco/service/sample/AddUserToGroup has responded with a status of 404 - Not Found.
404 Description: Requested resource is not available.
Message: [b]Group not found[/b]
Server: Alfresco Community Network v2.1.0 (R1 443) schema 62
Time: Dec 13, 2007 3:35:02 PM
Diagnostics: Inspect Web Script (org/EOC/AddUserToGroup.get)
That means getGroup returned undefined.That is the problem. Now I'm going to say what else I saw.While trying to make it work, I added another user to the group "Gerentes" and asked javascript what groups that user owned to, and the answer was:0f512522-9f92-11dc-b07e-f5d358f2ab67
That's the name and group id of the group "Gerentes". Each time I create a group and ask its name, the answer is something similar.I downloaded a nightbuild (alfresco 2.9) and tried the same (thinking it could be a bug), but it failed too. Anyway, as the new version brings a group in its database (EMAIL_CONTRIBUTORS) i tried to add a user to that group using webscript. And it worked!!.The main difference between that group and another created by me was that the group alfresco brought had as group id EMAIL_CONTRIBUTORS, the same as the name displayed in alfresco webclient admin console and not an encrypted style name.Any help will be accepted
Thanks