AnsweredAssumed Answered

Cannot Access Custom Fields in Profile

Question asked by risenhoover on Aug 19, 2008
Latest reply on Aug 21, 2008 by risenhoover
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 cm:person, 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

Outcomes