<?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: Pass chain parameters from document suggestion widget in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/pass-chain-parameters-from-document-suggestion-widget/m-p/317070#M4071</link>
    <description>&lt;P&gt;Ok, I think that I managed to solve this on my own (I don't even know why I still post stuff here, I never get any answer).&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The searchTerm parameter is automatically passed to the operation's parameters, so no need to include it in the "params" field of the widget.&lt;/LI&gt;
&lt;LI&gt;Things mess up when passing the parameters directly as a string representation of a javascript object. You should first create a javascript object in the Polymer script, then pass this object to the widget. Here's the fixed code :&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The widget :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nuxeo-document-suggestion  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;The 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", "docId": document.id}
			},
		},
	});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BUT my troubles are not over because my docId param is empty, which makes sense because my document is not created yet, and all its properties are empty.&lt;/P&gt;
&lt;P&gt;document.id or document.path both return a null value, and I have no idea how to get the parent's ref (that's my ultimate goal). If you have ANY idea please feel free to share.&lt;/P&gt;
&lt;P&gt;Have a good day !&lt;/P&gt;</description>
    <pubDate>Thu, 06 Aug 2020 13:44:54 GMT</pubDate>
    <dc:creator>Corentin_Bourdo</dc:creator>
    <dc:date>2020-08-06T13:44:54Z</dc:date>
    <item>
      <title>Pass chain parameters from document suggestion widget</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/pass-chain-parameters-from-document-suggestion-widget/m-p/317069#M4070</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to pass parameters from a nuxeo-document-suggestion widget to the automation chain returning the suggested documents.&lt;/P&gt;
&lt;P&gt;Here is the widget :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nuxeo-document-suggestion
	value="{{document.properties.mfs:documents}}"
	label="[[i18n('manufacturing_summary.documents')]]"
	multiple="true"
	min-chars="0"
	role="widget"
	stayOpenOnSelect="true"
	operation="SearchDocuments"
	params="{'searchTerm':'?', 'doctype':'hwp_document', 'parentId':'#{documentManager.getParentDocument(currentDocument.parentRef).id}'"
&amp;gt;&amp;lt;/nuxeo-document-suggestion&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And here is the automation chain :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;chain id="SearchDocuments"&amp;gt;
	&amp;lt;param type="string" name="searchTerm"/&amp;gt;
	&amp;lt;param type="string" name="doctype"/&amp;gt;
	&amp;lt;param type="string" name="parentId"/&amp;gt;
	&amp;lt;operation id="GetSearchQuery"&amp;gt;
		&amp;lt;param type="string" name="searchTerm"&amp;gt;expr:ChainParameters['searchTerm']&amp;lt;/param&amp;gt;
		&amp;lt;param type="string" name="doctype"&amp;gt;expr:ChainParameters['searchTerm']&amp;lt;/param&amp;gt;
		&amp;lt;param type="string" name="parentId"&amp;gt;expr:ChainParameters['parentId']&amp;lt;/param&amp;gt;
	&amp;lt;/operation&amp;gt;
	&amp;lt;operation id="Context.SetInputAsVar"&amp;gt;
		&amp;lt;param type="string" name="name"&amp;gt;query&amp;lt;/param&amp;gt;
	&amp;lt;/operation&amp;gt;
	&amp;lt;operation id="Repository.Query"&amp;gt;
		&amp;lt;param type="string" name="language"&amp;gt;NXQL&amp;lt;/param&amp;gt;
		&amp;lt;param type="string" name="query"&amp;gt;expr:Context['query']&amp;lt;/param&amp;gt;
		&amp;lt;param type="stringlist" name="sortBy"&amp;gt;dc:title&amp;lt;/param&amp;gt;
		&amp;lt;param type="stringlist" name="sortOrder"&amp;gt;ASC&amp;lt;/param&amp;gt;
	&amp;lt;/operation&amp;gt;
&amp;lt;/chain&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, I tried to pass them through the "params" field (as suggested by the &lt;A href="https://www.webcomponents.org/element/nuxeo/nuxeo-ui-elements/elements/nuxeo-document-suggestion#property-params"&gt;documentation&lt;/A&gt;), but :&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I'm really not sure about the "?" syntax for the search parameter&lt;/LI&gt;
&lt;LI&gt;The chain parameters are empty when they get called by the GetSearchQuery operation&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I could try to directly access those parameters from the automation context, but being called from a widget in the creation form, the current document (i.e. the parent of the document being created) is not accessible in this context.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 13:28:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/pass-chain-parameters-from-document-suggestion-widget/m-p/317069#M4070</guid>
      <dc:creator>Corentin_Bourdo</dc:creator>
      <dc:date>2020-07-22T13:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pass chain parameters from document suggestion widget</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/pass-chain-parameters-from-document-suggestion-widget/m-p/317070#M4071</link>
      <description>&lt;P&gt;Ok, I think that I managed to solve this on my own (I don't even know why I still post stuff here, I never get any answer).&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The searchTerm parameter is automatically passed to the operation's parameters, so no need to include it in the "params" field of the widget.&lt;/LI&gt;
&lt;LI&gt;Things mess up when passing the parameters directly as a string representation of a javascript object. You should first create a javascript object in the Polymer script, then pass this object to the widget. Here's the fixed code :&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The widget :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;nuxeo-document-suggestion  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;The 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", "docId": document.id}
			},
		},
	});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BUT my troubles are not over because my docId param is empty, which makes sense because my document is not created yet, and all its properties are empty.&lt;/P&gt;
&lt;P&gt;document.id or document.path both return a null value, and I have no idea how to get the parent's ref (that's my ultimate goal). If you have ANY idea please feel free to share.&lt;/P&gt;
&lt;P&gt;Have a good day !&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 13:44:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/pass-chain-parameters-from-document-suggestion-widget/m-p/317070#M4071</guid>
      <dc:creator>Corentin_Bourdo</dc:creator>
      <dc:date>2020-08-06T13:44:54Z</dc:date>
    </item>
  </channel>
</rss>

