AnsweredAssumed Answered

Add object type any by Javascript script

Question asked by fjcano on Feb 1, 2012
Hi,

I would like to add an any property by a javascript code. This is my current code:
————————————————————————————————————————————-

var feedIdValue = "1328091533886"
var feedIdParameter = "feedCode"
var feedPropertyName = "feedImage"


function Image() {
this.url='URL_ICON';
this.width=1;
this.height=2;
}


var feedPropertyValueNew =  new Image()

var query = "@xxx\\:" + feedIdParameter + ":\"" + feedIdValue + "\""
logger.log("Query " + query)

var feed = search.luceneSearch(query)[0];
logger.log("Found feed: " + feed)

var feedPropertyValueOld = feed.properties["{http://buongiorno.com/models/XXX/}" + feedPropertyName];
logger.log("Changing feed: " + feedIdValue + " " + feedPropertyName + ": " + feedPropertyValueOld + " to new value: " + feedPropertyValueNew);
feed.properties["{http://XXX.com/models/XXX/}" + feedPropertyName] = feedPropertyValueNew;
feed.save();

——————————————————————

By the node browser, it shows (after to execute the script):

Name: {http://XXX.com/models/XXX/}feedImage   
Value: {url=URL_ICON, width=1.0, height=2}
Property Type: {http://www.alfresco.org/model/dictionary/1.0}any   
Value Type: {http://www.alfresco.org/model/dictionary/1.0}any

Instead of (add by java webscript):

Name: {http://XXX.com/models/XXX/}feedImage   
Value: Image{url='https://s.sony.net/images/icon_rss.png', width=16, height=16}
Property Type: {http://www.alfresco.org/model/dictionary/1.0}any   
Value Type: {http://www.alfresco.org/model/dictionary/1.0}any

And my cast/read of the property does not work if I set the image by javascript.

Any idea?

Thanks in advance

Outcomes