Populate Multiple fields with document suggestion results

I'm trying to use the document suggestion results to populate multiple UI fields after selection. The only value accessible post-selection is the document id. Is there a way to return a document object after selection, or is there an API call that can be used to pull the document details (metadata) post-selection? I'm also thinking I could do a rest call to pull the document details if there is not a better way of doing so within studio.

//HTML segment

nuxeo-document-suggestion id=“BU” role=“widget” value=“{{document.properties.AP_Invoice:Route_CD}}” label=“BU” min-chars=“1” on-value-changed=“_getSuggestionDoc” enrichers=“thumbnail” result-formatter=“[[thumbnailFormatter]]” >

Polymer script seciton:

_getSuggestionDoc: function(e) {

alert(JSON.stringify(e.detail));
//_getThumbnailUrl: function(doc) {

   // retu "/nuxeo/api/v1/id/" + doc.;

}

0 votes

2 answers

187 views

ANSWER



You can use a <nuxeo-resource id="someId"><nuxeo-resource/> element to query the document with the document rest API endpoint for documents https://doc.nuxeo.com/nxdoc/rest-api-endpoints/, simply pass the endpoint url to the path property of the element.

Then you would have to handle the value change at the _getSuggestionDoc function, when the id changes you would simply call this.$.someId.get().then( //do something). If you need additional document info you can always add document enrichers.

1 votes



Thanks You ac !!!! I think this will work for this and tons of other use cases I'm working on! Much appreciated.

0 votes