cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Access Custom Fields in Profile

risenhoover
Champ in-the-making
Champ in-the-making
Hi all,

Here's another problem that has vexed me for the last few weeks.  The background is that I'd like to store some extra information about users in the profile, beyond what Alfresco offers.  This is with Alfresco Enterprise 2.2.0

I created a custom type that descends from the standard cmSmiley Tongueerson, as such:

      
    <type name="d3:person">
         <title>D3 Person</title>
         <parent>cm:person</parent>
         <properties>
            <property name="d3:telephone">
               <title>Telephone</title>
               <type>d:text</type>
            </property>
            <property name="d3:mobile">
               <title>Mobile</title>
               <type>d:text</type>
            </property>

            <!–  This is a "T" or "M" to identify preferred communication mechanism –>
            <property name="d3:preferred_comm">
               <title>Preferred Comm.</title>
               <type>d:text</type>
            </property>
         </properties>
      </type>

I created a web script called "profile" that gets the "person" object (which is the currently-authenticated user), and specializes it to my type, as such:


var my_person = person;

if ( my_person.specializeType("d3:person")) {
  logger.log("Specialized my_person to d3:person");
}

model.my_person = my_person;

And then I created a template that accesses the extra properties I created:


<?xml version="1.0" encoding="UTF-8"?>
<result>
    <first>${person.properties.firstName}</first>
    <last>${person.properties.lastName}</last>
    <email>${person.properties.email}</email>
    <title>NOT IMPLEMENTED</title>
    <office>${my_person.properties.telephone}</office>
    <cell>NOT IMPLEMENTED</cell>
    <primaryPhone>office</primaryPhone>
</result>

You'd think this would work, but it throws an exception, stating that it cannot find the "telephone" property in the my_person object.


org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expression my_person.properties.telephone is undefined on line 7, column 15 in test/profile/profile.get.xml.ftl.'. Please contact your system administrator.

Now I've tried changing the "${my_person.properties.telephone}" expression to all of it's various forms, including: …properties["telephone"], …properties["cm:telephone"], …properties["Telephone"] but nothing works.

I get this same exception over and over again.

Any thoughts?
Paul
8 REPLIES 8

mikeh
Star Contributor
Star Contributor
Did you try properties["d3:telephone"] ?

Mike

risenhoover
Champ in-the-making
Champ in-the-making
Yes.


Error during processing of the template 'Expression my_person.properties["d3:telephone"] is undefined on line 7, column 15 in test/profile/profile.get.xml.ftl.'. Please contact your system administrator.

mikeh
Star Contributor
Star Contributor
Ok. Try using the node browser from the JSF client and see what properties are on that person node.

Thanks,
Mike

risenhoover
Champ in-the-making
Champ in-the-making
Ok, so this is a little disconcerting.  I went to the node browser and drilled down through the user://alfrescoUserStore space and found the container that contains sixteen children, which corresponds to the size of my estimated user list.

When I click on each of them, I get the same user.  If I traverse back up, and then back down, and click on a user, I get a different user for each of the children.  Rinse, wash, repeat.

I've rebuilt my Lucene indices already once today and the only user management I've performed since then is to change a user's password, so what could be causing this?

mikeh
Star Contributor
Star Contributor
You're not using the back button or a new browser tab/window to follow the child links are you? You have to click through the node browser using <click>child<click>link to parent<click>2nd child, etc.

The way to check if you're really looking at the child node you expect is to check the nodeRef of the current record at the top.

Thanks,
Mike

risenhoover
Champ in-the-making
Champ in-the-making
Yes I was using the back button….

Ok so when I examine my user node, I do not see any of the extra fields I defined.  If I execute a POST command on the profile that specializes the cmSmiley Tongueerson to a d3Smiley Tongueerson and then adds the extra field, it does not throw an error.  However, that new attribute still does not show up in the node browser.

mikeh
Star Contributor
Star Contributor
Did you remember to call my_person.save() ?

Thanks,
Mike

risenhoover
Champ in-the-making
Champ in-the-making
I'm doing it on the POST but not on the GET.