cancel
Showing results for 
Search instead for 
Did you mean: 

how to add custom properties in alfresco

ramesh_ram
Champ in-the-making
Champ in-the-making
Dear All,

While adding conetent in the UI we will see some default properties,

Now I want add some more properties, like FirstName,EmailID,Ph no,
address etc. . How to add these properties.

Thanks in advance,
ramesh
10 REPLIES 10

jordiv
Champ on-the-rise
Champ on-the-rise

ramesh_ram
Champ in-the-making
Champ in-the-making
Dear Jordi,

Thanks for your reply,
I created ramesh as user and ssdg_space for that user..
When ever ramesh(user) enters a document in this space
custom properties has also along with default properties.
I hope you understand my requirement.

jordiv
Champ on-the-rise
Champ on-the-rise
If you want to apply your default properties to any document created in a specific folder, you can do it using a rule.

First you should define your custom aspect, and then create a folder rule that applies that aspect to any document created in it.
You can create rules by clicking the "Manage Rules" in the folder details page.

Cheers,
Jordi.

ramesh_ram
Champ in-the-making
Champ in-the-making
thanks  jordiv,

I am new buddy in alfresco,

I followed the blog posted by you, how to add custom properties.
I coppied that code into extention folder of my project, still I am
not getting the custom properties in alfresco explorer.

Could you please expalin me more about how to add custom properties.

jordiv
Champ on-the-rise
Champ on-the-rise
I'm not an expert but I'll try.

As I understand it, there are two ways of adding new properties into Alfresco content model: Defining either a Type or an Aspect.
These concepts are very similar. Just that a node can have only one type but a lot of aspects.

So, to define a new aspect 3 files are involved:
  • myModel.xml: Where your model is defined.

  • myexample-model-context.xml: This file is to tell Alfresco about your model.

  • mymodel.properties: Labels file.
myModel.xml:

<?xml version="1.0" encoding="UTF-8"?>
<model name="my:example" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <description>Sample Model</description>
    <author>jordiv</author>
    <version>1.0</version>
    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
    </imports>
    <namespaces>
        <namespace uri="http://www.jordiv.com/model/content/1.0" prefix="my"/>
    </namespaces>
    <aspects>
        <aspect name="my:sampleProps">
            <title>Sample Aspect by jordiv</title>
            <properties>
                <property name="my:propOne">
                    <title>Property 1</title>
                    <type>d:text</type>
                </property>
                <property name="my:propTwo">
                    <title>Property 2</title>
                    <type>d:text</type>
                </property>
            </properties>
        </aspect>
    </aspects>
</model>

myexample-model-context.xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
    <bean id="example.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/myModel.xml</value>
            </list>
        </property>
        <property name="labels">
            <list>
                <value>alfresco/extension/mymodel</value>
            </list>
        </property>
    </bean>
</beans>

mymodel.properties

my_model.description=Sample Model

These files should be placed in:
/tomcat/shared/classes/alfresco/extension/

Then check if you have a file named web-client-config-custom.xml in that folder. If you don't, create it. If you already have it, just add the following lines.

web-client-config-custom.xml

<alfresco-config>
     <config evaluator="aspect-name" condition="my:sampleProps">
         <property-sheet>
             <show-property name="my:propOne"/>
             <show-property name="my:propTwo"/>
        </property-sheet>
    </config>
    <config evaluator="string-compare" condition="Action Wizards">
        <aspects>
            <aspect name="my:sampleProps" />
        </aspects>
    </config>
</alfresco-config>

Then restart Alfresco.

With this, your new Aspect will become available from the Explorer interface.
To try it, go to the details page of any document and click in "Run Action". Select the "Add aspect" action, and in the list you will find the 'Sample Aspect by jordiv' aspect.
Once you complete the action, your document will have the two new properties defined in the aspect.


Hope this helps.

Cheers,
Jordi.

ramesh_ram
Champ in-the-making
Champ in-the-making
thanks a lot Jordi,

Your sample files are working, once again thanks. one small doubt, is our custom properties will store in alfresco database.(Do you have any idea about workflows)

jordiv
Champ on-the-rise
Champ on-the-rise
You're welcome!

I don't know where exactly the properties are stored, maybe an Alfresco Engineer could answer that.
I have little experience with workflows. If you have any specific problem, you should post your question in the Workflow forum.

Cheers,
Jordi.

ramesh_ram
Champ in-the-making
Champ in-the-making
Hi Jordi,

I am posting my custom workflow doubt in workflow forum, please check it once.

mahesh2
Champ in-the-making
Champ in-the-making
Hi ramesh,
   
      can u provide snapshots for ur working files,iam using 4.2 version.



Thanks in advance.