Nuxeo 5.8 - Single document suggestion - doc schema dublin core not all fields visible in inline JavaScript

Hello,

In Nuxeo 5.8 try to use the single document suggestion widget with inline javascript.

Document schema are set to “dublincore” and also my custom schema. Nevertheless this value are not used by inline javascript because I can just see “title” and “path” as results.

function myFormatter(entry) {
var markup = entry.title + " " + entry.description + " " + entry.mycustom + " " + entry.path;
return markup;
}

Here, entry.description and all dublincore fields such as author failed… entry.mycustom failed too. But this fields exists on the document(s) suggested ant selected…

Why ? Is my code wrong ?

thanks

0 votes

1 answers

2460 views

ANSWER



Hello me,

First I did Json neewbie investigations :

function myFormatter(entry) {
var markup = JSON.stringify(entry);
return markup;
}

This method show ALL the properties that exist in the objet of work named “entry”.

In the properties it looks like that xpath value are not such as default value.

Default values are: entity-type, type, state, versionLabel, title, lastModified, path, isCheckedOut,repository,uid…

And then comes “properties” that is hashMap Json. Here a function to read a special tab in entry.properties and also show a classic propertie “path”

function myFormatter(entry) {
var markup = entry.title + " simple acces " + entry.properties["dc:description"] + " test json " + readJSONTab(readJSONTab(entry,"properties"),"dc:description") ";
return markup;
}

//Test Json
function readJSONTab(data,tagExtracted){
var json = JSON.parse(JSON.stringify(data))
return json[tagExtracted];
}

PS : To use other kind of xpath properties, have fun with this start and use JSON javascript function

PS 2 : http://msdn.microsoft.com/fr-fr/library/ie/cc836466(v=vs.94).aspx JSON.parse need a character chain NOT an objet. So, use JSON.stringify on your objects first.

1 votes



Yes, you got it. Any schema properties can simply be accessed via entry.properties["xx:property_name"] where xx is a schema prefix.
01/20/2014