0

I create a product of type abc:product with a product Id - 12345 (for example) in the abc:productId field.

I have a type called abc:productContent with the abc:productNumber field. Now when I'm creating the document of type abc:productContent, I'm trying to populate the abc:productNumber field with the value of the above mentioned product Id of abc:product object (and make the field read only).

How to achieve the above?

Thank you for the help

Nikhil A A
  • 441
  • 1
  • 4
  • 17
  • Looks like you are trying to emulate foreign key style references. You may want to have a look at associations instead. That said, what exactly is holding you back setting abc:productNumber ? Depending on your requirement there are several options to implement read-only properties. – Andreas Steffan Mar 20 '14 at 10:47
  • I've created a form in share-config-custom.xml for abc:productContent and abc:product. I've a dashlet which shows the details (properties) of the abc:product object. In that dashlet I've a "Create Product Content" button. When I click on it, it is forwarded to create-content?destination=some-folder-path&itemId=abc:productContent. Here in this create content page I would like to populate abc:productNumber field with the value of productId value shown in the dashlet. – Nikhil A A Mar 20 '14 at 14:11

1 Answers1

2

You need a form definition such as:

<alfresco-config>
<!-- ...  -->
<config evaluator="model-type" condition="abc:productContent">
    <forms>
        <form>
            <field-visibility>
                <!-- ... other fields -->
                <show id="abc:productNumber"/>
                <!-- ... more fields -->
            </field-visibility>
            <appearance>

                <!-- ...  other fields -->
                <field id="abc:productNumber" mandatory="true">
                    <control template="/xxx/value-from-url.ftl" />
                </field>
                <!--  ... even more ...>
            </appearance>
        </form>
    </forms>
</config>
<!--  ... -->
<alfresco-config>

Append the a parameter with the productNumber value you want to the create-content link in the dashlet.

In your custom value-from-url.ftl (see /org/alfresco/components/form/controls/*.ftl for examples), get the value from the url and put it in the input field.

Andreas Steffan
  • 6,039
  • 2
  • 23
  • 25