<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get noderef in a custom dialog template in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9869#M4393</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure - "file" is not defined because you have not provided it anywhere to the client-side JavaScript function and there is no magic "file" in the context of the form control rendering request. If this is an edit/view form, then you will have the "form.arguments.itemId" variable in the FTL context, which might be a NodeRef (if the form is rendered for one).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Feb 2017 11:25:14 GMT</pubDate>
    <dc:creator>afaust</dc:creator>
    <dc:date>2017-02-10T11:25:14Z</dc:date>
    <item>
      <title>How to get noderef in a custom dialog template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9868#M4392</link>
      <description>Hi,I have created a custom dialog freemarker template for my custom field that I am using as itemkind in my custom action. The custom field will be auto populated with some values specific to a node and shown as a dropdown for user to choose a value. The&amp;nbsp;custom dialog freemarker&amp;nbsp;template for this fi</description>
      <pubDate>Fri, 10 Feb 2017 05:36:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9868#M4392</guid>
      <dc:creator>hiten_rastogi1</dc:creator>
      <dc:date>2017-02-10T05:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get noderef in a custom dialog template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9869#M4393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sure - "file" is not defined because you have not provided it anywhere to the client-side JavaScript function and there is no magic "file" in the context of the form control rendering request. If this is an edit/view form, then you will have the "form.arguments.itemId" variable in the FTL context, which might be a NodeRef (if the form is rendered for one).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 11:25:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9869#M4393</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2017-02-10T11:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get noderef in a custom dialog template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9870#M4394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use&amp;nbsp;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;STRONG&gt;form.arguments.itemId&lt;/STRONG&gt; to get the value of nodeRef I get&amp;nbsp;&lt;STRONG&gt;version-delete &lt;/STRONG&gt;as the value which is the itemId in my custom action. Below is the form that I am using and the corresponding action that invoke that form.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #000000;"&gt;&lt;STRONG&gt;FORM&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;blockcode&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;config evaluator="string-compare"&amp;nbsp;condition="version-delete"&amp;gt; &amp;lt;!-- ID for the Repository Action that this form is associated with --&amp;gt;&lt;BR /&gt; &amp;lt;forms&amp;gt;&lt;BR /&gt; &amp;lt;form&amp;gt;&lt;BR /&gt; &amp;lt;field-visibility&amp;gt;&lt;BR /&gt; &amp;lt;show id="version"/&amp;gt;&lt;BR /&gt; &amp;lt;/field-visibility&amp;gt;&lt;BR /&gt; &amp;lt;appearance&amp;gt;&lt;BR /&gt; &amp;lt;field id="version" label-id="action.versionDelete.form.field.version"&amp;gt;&lt;BR /&gt; &amp;lt;control template="/form-controls/version-dropdown.ftl" &amp;nbsp;/&amp;gt;&lt;BR /&gt; &amp;lt;/field&amp;gt;&lt;BR /&gt; &amp;lt;/appearance&amp;gt;&lt;BR /&gt; &amp;lt;/form&amp;gt;&lt;BR /&gt; &amp;lt;/forms&amp;gt;&lt;BR /&gt; &amp;lt;/config&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;/blockcode&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #000000;"&gt;&lt;STRONG&gt;ACTION&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;action id="action.versionDelete" type="javascript"&amp;nbsp;label="action.versionDelete.label"&amp;gt;&lt;BR /&gt; &amp;lt;param name="function"&amp;gt;onActionFormDialog&amp;lt;/param&amp;gt;&lt;BR /&gt; &amp;lt;param name="itemKind"&amp;gt;action&amp;lt;/param&amp;gt;&lt;BR /&gt; &amp;lt;param name="itemId"&amp;gt;version-delete&amp;lt;/param&amp;gt; &amp;lt;!-- Repository action id = Spring Bean id --&amp;gt;&lt;BR /&gt; &amp;lt;param name="mode"&amp;gt;create&amp;lt;/param&amp;gt;&lt;BR /&gt; &amp;lt;param name="destination"&amp;gt;{node.nodeRef}&amp;lt;/param&amp;gt;&lt;BR /&gt; &amp;lt;param name="successMessage"&amp;gt;action.versionDelete.msg.success&amp;lt;/param&amp;gt;&lt;BR /&gt; &amp;lt;param name="failureMessage"&amp;gt;action.versionDelete.msg.failure&amp;lt;/param&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;/action&amp;gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Feb 2017 07:30:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9870#M4394</guid>
      <dc:creator>hiten_rastogi1</dc:creator>
      <dc:date>2017-02-13T07:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to get noderef in a custom dialog template</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9871#M4395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was finally able to get the nodeRef in my custom ftl which was used in a field of a form which was invoked by an action. It seems if you define&lt;STRONG&gt;&amp;nbsp;&amp;lt;param name="destination"&amp;gt;{node.nodeRef}&amp;lt;/param&amp;gt;&amp;nbsp;&lt;/STRONG&gt;in your action alfresco includes the noderef as a hidden input field with id as "&lt;STRONG&gt;alf-id24-form-destination&lt;/STRONG&gt;" where &lt;STRONG&gt;alf-id24&lt;/STRONG&gt; is a part of fieldHtmlId e.g in my case&amp;nbsp;&lt;SPAN&gt;fieldHtmlId was coming as&amp;nbsp;&lt;SPAN&gt;alf-id24&lt;/SPAN&gt;_prop_version. You can do &lt;STRONG&gt;document.getElementById("alf-id24-form-destination").value&lt;/STRONG&gt;&amp;nbsp;or&amp;nbsp;&lt;STRONG&gt;YAHOO.util.Dom.get("&lt;STRONG&gt;alf-id24-form-destination"&lt;/STRONG&gt;).value&amp;nbsp;&lt;/STRONG&gt;to get the nodeRef. Full code of ftl below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;#include "/org/alfresco/components/form/controls/common/utils.inc.ftl" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script type="text/javascript"&amp;gt;//&amp;lt;![CDATA[&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YAHOO.util.Event.onContentReady("${fieldHtmlId}", function ()&lt;BR /&gt;{&lt;BR /&gt; var fieldHtmlIdToken = "${fieldHtmlId}".split("_");&lt;BR /&gt; var nodeRef = document.getElementById(fieldHtmlIdToken[0]+"-form-destination").value;&lt;BR /&gt; //var nodeRef = YAHOO.util.Dom.get(fieldHtmlIdToken[0]+"-form-destination").value;&lt;BR /&gt; &lt;BR /&gt; Alfresco.util.Ajax.jsonGet({&lt;BR /&gt; url: encodeURI(Alfresco.constants.PROXY_URI + 'api/version?nodeRef='+nodeRef),&lt;BR /&gt; successCallback:&lt;BR /&gt; {&lt;BR /&gt; fn: function loadWebscript_successCallback(response, config)&lt;BR /&gt; {&lt;BR /&gt; var obj = JSON.parse(response.serverResponse.responseText);&lt;BR /&gt; if (obj)&lt;BR /&gt; {&lt;BR /&gt; for (i = 0; i &amp;lt; obj.length; i++) {&lt;/P&gt;&lt;P&gt;// avoid the latest version from getting displayed&lt;BR /&gt; if(i===0){&lt;BR /&gt; continue;&lt;BR /&gt; }&lt;BR /&gt; var newOption = document.createElement('option');&lt;BR /&gt; newOption.value = obj[i].label;&lt;BR /&gt; newOption.text = obj[i].label;&lt;BR /&gt; YAHOO.util.Dom.get("${fieldHtmlId}").options.add(newOption);&lt;BR /&gt; }&lt;BR /&gt; // Current value&lt;BR /&gt; var sp = document.getElementById("${fieldHtmlId}");&lt;BR /&gt; sp.value = "${field.value}";&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt;}, this);&lt;BR /&gt;//]]&amp;gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;#if field.control.params.optionSeparator??&amp;gt;&lt;BR /&gt; &amp;lt;#assign optionSeparator=field.control.params.optionSeparator&amp;gt;&lt;BR /&gt;&amp;lt;#else&amp;gt;&lt;BR /&gt; &amp;lt;#assign optionSeparator=","&amp;gt;&lt;BR /&gt;&amp;lt;/#if&amp;gt;&lt;BR /&gt;&amp;lt;#if field.control.params.labelSeparator??&amp;gt;&lt;BR /&gt; &amp;lt;#assign labelSeparator=field.control.params.labelSeparator&amp;gt;&lt;BR /&gt;&amp;lt;#else&amp;gt;&lt;BR /&gt; &amp;lt;#assign labelSeparator="|"&amp;gt;&lt;BR /&gt;&amp;lt;/#if&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;#assign fieldValue=field.value&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;#if fieldValue?string == "" &amp;amp;&amp;amp; field.control.params.defaultValueContextProperty??&amp;gt;&lt;BR /&gt; &amp;lt;#if context.properties[field.control.params.defaultValueContextProperty]??&amp;gt;&lt;BR /&gt; &amp;lt;#assign fieldValue = context.properties[field.control.params.defaultValueContextProperty]&amp;gt;&lt;BR /&gt; &amp;lt;#elseif args[field.control.params.defaultValueContextProperty]??&amp;gt;&lt;BR /&gt; &amp;lt;#assign fieldValue = args[field.control.params.defaultValueContextProperty]&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt;&amp;lt;/#if&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;div class="form-field"&amp;gt;&lt;BR /&gt; &amp;lt;#if form.mode == "view"&amp;gt;&lt;BR /&gt; &amp;lt;div class="viewmode-field"&amp;gt;&lt;BR /&gt; &amp;lt;#if field.mandatory &amp;amp;&amp;amp; !(fieldValue?is_number) &amp;amp;&amp;amp; fieldValue?string == ""&amp;gt;&lt;BR /&gt; &amp;lt;span class="incomplete-warning"&amp;gt;&amp;lt;img src="${url.context}/res/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /&amp;gt;&amp;lt;span&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;span class="viewmode-label"&amp;gt;${field.label?html}:&amp;lt;/span&amp;gt;&lt;BR /&gt; &amp;lt;#if fieldValue?string == ""&amp;gt;&lt;BR /&gt; &amp;lt;#assign valueToShow=msg("form.control.novalue")&amp;gt;&lt;BR /&gt; &amp;lt;#else&amp;gt;&lt;BR /&gt; &amp;lt;#assign valueToShow=fieldValue&amp;gt;&lt;BR /&gt; &amp;lt;#if field.control.params.options?? &amp;amp;&amp;amp; field.control.params.options != ""&amp;gt;&lt;BR /&gt; &amp;lt;#list field.control.params.options?split(optionSeparator) as nameValue&amp;gt;&lt;BR /&gt; &amp;lt;#if nameValue?index_of(labelSeparator) == -1&amp;gt;&lt;BR /&gt; &amp;lt;#if nameValue == fieldValue?string || (fieldValue?is_number &amp;amp;&amp;amp; fieldValue?c == nameValue)&amp;gt;&lt;BR /&gt; &amp;lt;#assign valueToShow=nameValue&amp;gt;&lt;BR /&gt; &amp;lt;#break&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;#else&amp;gt;&lt;BR /&gt; &amp;lt;#assign choice=nameValue?split(labelSeparator)&amp;gt;&lt;BR /&gt; &amp;lt;#if choice[0] == fieldValue?string || (fieldValue?is_number &amp;amp;&amp;amp; fieldValue?c == choice[0])&amp;gt;&lt;BR /&gt; &amp;lt;#assign valueToShow=msgValue(choice[1])&amp;gt;&lt;BR /&gt; &amp;lt;#break&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;/#list&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;span class="viewmode-value"&amp;gt;${valueToShow?html}&amp;lt;/span&amp;gt;&lt;BR /&gt; &amp;lt;/div&amp;gt;&lt;BR /&gt; &amp;lt;#else&amp;gt;&lt;BR /&gt; &amp;lt;label for="${fieldHtmlId}"&amp;gt;${field.label?html}:&amp;lt;#if field.mandatory&amp;gt;&amp;lt;span class="mandatory-indicator"&amp;gt;${msg("form.required.fields.marker")}&amp;lt;/span&amp;gt;&amp;lt;/#if&amp;gt;&amp;lt;/label&amp;gt;&lt;BR /&gt; &amp;lt;select id="${fieldHtmlId}" name="${field.name}" tabindex="0"&lt;BR /&gt; &amp;lt;#if field.description??&amp;gt;title="${field.description}"&amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;#if field.control.params.size??&amp;gt;size="${field.control.params.size}"&amp;lt;/#if&amp;gt; &lt;BR /&gt; &amp;lt;#if field.control.params.styleClass??&amp;gt;class="${field.control.params.styleClass}"&amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;#if field.control.params.style??&amp;gt;style="${field.control.params.style}"&amp;lt;/#if&amp;gt;&lt;BR /&gt; &amp;lt;#if field.disabled &amp;amp;&amp;amp; !(field.control.params.forceEditable?? &amp;amp;&amp;amp; field.control.params.forceEditable == "true")&amp;gt;disabled="true"&amp;lt;/#if&amp;gt;&amp;gt;&lt;BR /&gt; &amp;lt;/select&amp;gt;&lt;BR /&gt; &amp;lt;@formLib.renderFieldHelp field=field /&amp;gt;&lt;BR /&gt; &amp;lt;/#if&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 05:52:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-in-a-custom-dialog-template/m-p/9871#M4395</guid>
      <dc:creator>hiten_rastogi1</dc:creator>
      <dc:date>2017-02-17T05:52:50Z</dc:date>
    </item>
  </channel>
</rss>

