<?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 Document suggestion operation always called with init params in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/document-suggestion-operation-always-called-with-init-params/m-p/315993#M2994</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;This is a follow-up of &lt;A href="https://answers.nuxeo.com/general/q/1ed695adad8745c38238867653677c38/Pass-chain-parameters-from-document-suggestion-widget"&gt;this question&lt;/A&gt;, I am creating a new one because I'm trying a different approach. You should read it to have the first part of the story.&lt;/P&gt;
&lt;P&gt;In short :
I've got a document suggestion widget in the creation form of an "index" document which will summarize all the documents for a given project. This widget searches for documents by calling a custom operation. This custom operation has a "parentsIds" parameter which serves as a filter, so that you don't have to scroll through all documents on the Nuxeo instance, but only the ones that are related to the project.&lt;/P&gt;
&lt;P&gt;At first I tried to pass the id of the "index" document being created so I could get its parent (that was the first question if you haven't read it), but the document does not have an id yet in the creation form, so I added another document suggestion widget to select folders in which the second widget is going to search.&lt;/P&gt;
&lt;P&gt;This new widget has a valueChanged listener updating the params.&lt;/P&gt;
&lt;P&gt;Here are the two widgets :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nuxeo-document-suggestion  value=""
							label="[[i18n('manufacturing_summary.documentsLocations')]]"
							multiple="true"
							min-chars="0"
							role="widget"
							placeholder="[[i18n('dublincoreEdit.directorySuggestion.placeholder')]]"
							operation="SearchHWProjects"
							on-value-changed="_documentsLocationsUpdated"
&amp;gt;&amp;lt;/nuxeo-document-suggestion&amp;gt;

&amp;lt;nuxeo-document-suggestion  id="documentSuggestionWidget"
							value="{{document.properties.mfs:documents}}"
							label="[[i18n('manufacturing_summary.documents')]]"
							multiple="true"
							min-chars="0"
							role="widget"
							placeholder="[[i18n('dublincoreEdit.directorySuggestion.placeholder')]]"
							operation="SearchDocuments"
							params="[[params]]"
&amp;gt;&amp;lt;/nuxeo-document-suggestion&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the corresponding script :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script&amp;gt;
	Polymer({
		is: 'nuxeo-manufacturing_summary-create-layout',
		behaviors: [Nuxeo.LayoutBehavior],
		properties: {
			/**
			 * @doctype manufacturing_summary
			 */
			document: Object,

			params: {
				type: Object,
				value: {'doctype': 'hwp_document', 'parentsIds': ''},
			}
		},

		_documentsLocationsUpdated: function (event) {
			if (event &amp;amp;&amp;amp; event.detail &amp;amp;&amp;amp; event.detail.value) {
				this.params.parentsIds = JSON.stringify(event.detail.value);
			}
		},
	});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Everything is working fine, the Polymer and the widget's params properties are updated when a parent is selected in the "filter" widget, BUT the operation is always called with the first specified parameters, i.e. the hard-coded value in the Polymer properties, no matter how many times it is modified... Weird right ?&lt;/P&gt;
&lt;P&gt;Any help welcome !
Have a good day&lt;/P&gt;</description>
    <pubDate>Mon, 10 Aug 2020 09:28:04 GMT</pubDate>
    <dc:creator>Corentin_Bourdo</dc:creator>
    <dc:date>2020-08-10T09:28:04Z</dc:date>
    <item>
      <title>Document suggestion operation always called with init params</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/document-suggestion-operation-always-called-with-init-params/m-p/315993#M2994</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;This is a follow-up of &lt;A href="https://answers.nuxeo.com/general/q/1ed695adad8745c38238867653677c38/Pass-chain-parameters-from-document-suggestion-widget"&gt;this question&lt;/A&gt;, I am creating a new one because I'm trying a different approach. You should read it to have the first part of the story.&lt;/P&gt;
&lt;P&gt;In short :
I've got a document suggestion widget in the creation form of an "index" document which will summarize all the documents for a given project. This widget searches for documents by calling a custom operation. This custom operation has a "parentsIds" parameter which serves as a filter, so that you don't have to scroll through all documents on the Nuxeo instance, but only the ones that are related to the project.&lt;/P&gt;
&lt;P&gt;At first I tried to pass the id of the "index" document being created so I could get its parent (that was the first question if you haven't read it), but the document does not have an id yet in the creation form, so I added another document suggestion widget to select folders in which the second widget is going to search.&lt;/P&gt;
&lt;P&gt;This new widget has a valueChanged listener updating the params.&lt;/P&gt;
&lt;P&gt;Here are the two widgets :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nuxeo-document-suggestion  value=""
							label="[[i18n('manufacturing_summary.documentsLocations')]]"
							multiple="true"
							min-chars="0"
							role="widget"
							placeholder="[[i18n('dublincoreEdit.directorySuggestion.placeholder')]]"
							operation="SearchHWProjects"
							on-value-changed="_documentsLocationsUpdated"
&amp;gt;&amp;lt;/nuxeo-document-suggestion&amp;gt;

&amp;lt;nuxeo-document-suggestion  id="documentSuggestionWidget"
							value="{{document.properties.mfs:documents}}"
							label="[[i18n('manufacturing_summary.documents')]]"
							multiple="true"
							min-chars="0"
							role="widget"
							placeholder="[[i18n('dublincoreEdit.directorySuggestion.placeholder')]]"
							operation="SearchDocuments"
							params="[[params]]"
&amp;gt;&amp;lt;/nuxeo-document-suggestion&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the corresponding script :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;script&amp;gt;
	Polymer({
		is: 'nuxeo-manufacturing_summary-create-layout',
		behaviors: [Nuxeo.LayoutBehavior],
		properties: {
			/**
			 * @doctype manufacturing_summary
			 */
			document: Object,

			params: {
				type: Object,
				value: {'doctype': 'hwp_document', 'parentsIds': ''},
			}
		},

		_documentsLocationsUpdated: function (event) {
			if (event &amp;amp;&amp;amp; event.detail &amp;amp;&amp;amp; event.detail.value) {
				this.params.parentsIds = JSON.stringify(event.detail.value);
			}
		},
	});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Everything is working fine, the Polymer and the widget's params properties are updated when a parent is selected in the "filter" widget, BUT the operation is always called with the first specified parameters, i.e. the hard-coded value in the Polymer properties, no matter how many times it is modified... Weird right ?&lt;/P&gt;
&lt;P&gt;Any help welcome !
Have a good day&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 09:28:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/document-suggestion-operation-always-called-with-init-params/m-p/315993#M2994</guid>
      <dc:creator>Corentin_Bourdo</dc:creator>
      <dc:date>2020-08-10T09:28:04Z</dc:date>
    </item>
  </channel>
</rss>

