Thursday, February 26, 2015

Alfresco - reusing printed xpaths in javascript console

I had to hand export import via javascript console some custom node properties (categories) and association, which was done via xpaths, because the nodeRefs store in source system did not match the targets. But i found out that i had to use this little encode function to make it work:

function enc(nonenc) {
    return jsonUtils.encodeJSONString(nonenc)


It encodes the international characters to escaped UTF like '\u00F8' instead of 'ΓΈ' and removes the "\/" and escapes backslashes.

Used it in export:
  var xpath = enc(node.qnamePath);

And in import:
  var nodes = search.xpathSearch(xpath);

No comments:

Post a Comment