cancel
Showing results for 
Search instead for 
Did you mean: 

Potential Share Association Issue

eamell
Champ in-the-making
Champ in-the-making
I have a client on Alfresco Enterprise 4.1.2 who wants to be able to click the attachments for a custom type to be able to navigate to the attachments.  A quick look at the Forms wiki and this seems pretty straight forward.  I added the following to my Share custom config:


<field id="cm:attachments">
   <control template="/org/alfresco/components/form/controls/association.ftl">
      <control-param name="displayMode">list</control-param>
      <control-param name="showTargetLink">true</control-param>
   </control>
</field>


I test it first on an email and it works beautifully.  I then click the link for one of the attachments and I get the following error on the details screen for the attachment (I have trimmed it for readability):

<blockquote>
2013-07-08 13:52:00,181  ERROR [freemarker.runtime] [http-8080-1] Template processing error: "Expression field.endpointType is undefined on line 22, column 20 in org/alfresco/components/form/controls/association.ftl."

Expression field.endpointType is undefined on line 22, column 20 in org/alfresco/components/form/controls/association.ftl.
The problematic instruction:
———-
==> ${field.endpointType} [on line 22, column 18 in org/alfresco/components/form/controls/association.ftl]
in include "${field.control.template}" [on line 90, column 7 in org/alfresco/components/form/form.lib.ftl]
in user-directive renderField [on line 121, column 13 in org/alfresco/components/form/form.lib.ftl]
in user-directive formLib.renderSet [on line 23, column 16 in org/alfresco/components/form/form.get.html.ftl]
in user-directive formLib.renderFormContainer [on line 20, column 7 in org/alfresco/components/form/form.get.html.ftl]
———-

Java backtrace for programmers:
———-
freemarker.core.InvalidReferenceException: Expression field.endpointType is undefined on line 22, column 20 in org/alfresco/components/form/controls/association.ftl.
</blockquote>

At this point I figured I could work around it.  I created my own association.ftl (we will call it myAssociation.ftl) where I made one change to line 22 as follows:

<javascript>
      itemType: "${field.endpointType!"cm:cmobject"}",
</javascript>

I added the !"cmSmiley Surprisedbject" part.  This sort of worked.  Now the page comes up but I get a property for cm:attachments (not Attachments) on the attached file.  This is better than it failing but it should just be ignoring it all together.

Is this a bug or am I doing something wrong?
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

if you leave out the template on your control, this problem should solve itself.
The cm:attachments association is tied to a specific aspect, so it is not always set. In situations where it isn't set (does not have a value), the Forms service Alfresco of the Repository does not generate the necessary description for Share to build a field upon it. When you put a control with a template on a field in Share form configuration, you are essentially doing a force=true, but without the necessary Repository data, e.g. for labels and stuff. If you don't, the default behavior is to only show a field if it actually applies to the current node. Share will automatically use the association.ftl without you having to specify it manually.

This is an explicit "transient" field behavior of Alfresco for use-cases where you want to build your own form without having a clear-cut data model on the Repository.

Regards
Axel

eamell
Champ in-the-making
Champ in-the-making
If I leave out the template then there are no links to click the document.  I need to customize the control with the displayMode and showTargetLink.  I tried explicitly setting force to false but I guess having the template overrides it.

eamell
Champ in-the-making
Champ in-the-making
Maybe I should try reading your post Smiley Happy.  I get what you were saying now.  I need the control and the control params but not the template attribute of the control.  Thanks for the help that worked!

eamell
Champ in-the-making
Champ in-the-making
So just to clarify for anyone else seeing this issue my config should have read:

<field id="cm:attachments">
   <control>
      <control-param name="displayMode">list</control-param>
      <control-param name="showTargetLink">true</control-param>
   </control>
</field>