1
votes

Alfresco 6.0.1. I'm trying to get the node reference for the current user's home in the repository, from a form control?

So suppose I have the following form configuration in share-config-custom.xml

<config>
<forms>
<dependencies>
</dependencies>
<form id="uploadMIForm">
  <field-visibility>
    <show id="miNode" />
  </field-visibility>
<appearance>
  <field id="miNode" label-id="prop.search.cm_search_in_folder" >
    <control template="controls/managementinfo/picker.ftl">
    </control>
  </field>
</appearance>
</form>
</forms>
</config>

And the controls/management/picker.ftl has a configuration option

picker.setOptions(
  ...
  parentNodeRef: "workspace://SpacesStore/a3c5f348-355d-4e7d-86a7-8e55bafd4662",
...
)

Question is, how do I dynamically get a node reference for the user's home, rather than hardcode it?

I've tried accessing the 'userhome' object in my ftl, according to the Alfresco Freemarker API reference documentation -

https://docs.alfresco.com/6.0/references/API-FreeMarker-defaultmodel.html

So from this, I expect that the statement

parentNodeRef: ${userhome.properties.nodeRef},

To do the job. But unfortunately I get a run time error as it evaluates to null.

Where am I going wrong? And how do I get this elusive node reference?

1
Be aware that Alfresco can render FTLs in two layers, the Alfresco / Repository layer, and the Share layer. You need to make sure you're reading the docs for the right one to see what's available! - Gagravarr
I'm pretty sure this is a Share layer issue, because the rendering error appears in the Share log. Now because I'm getting null value, I guess that I'm looking at the wrong object. - Andrew Fielden

1 Answers

1
votes

That userhome object is not in the browser's context, it is in the server's context. So it won't work.

How about writing a simple repository tier web script that returns the node reference of the current user's user home folder in JSON? Then you can just fire off a client-side JavaScript request against the Share proxy (which will invoke your Alfresco tier web script) to fetch the JSON containing the node reference.