Update date property

cancel
Showing results for 
Search instead for 
Did you mean: 
sercama
Active Member II

Update date property

Hello everybody,

I have to update a custom date property from a node of my Alfresco installation. So, I run next javascript code:

var node = search.luceneSearch('@sys\\:node-uuid:"abd3a8f7-66a5-4288-bf29-b9f31510cecb"');
node = node[0]; //get node to update


node.properties["xxx:customDate"] = "2017-03-31T13:14:17";
node.save();
print(node.properties["xxx:customDate"]);

Output is:

2017-03-31T13:14:17

However, If I explore this node in node browser, property xxx:customDate, whose is type d:date, has got old value.

Have you any idea how update a custom date propery?

Thanks.

2 Replies
afaust
Master

Re: Update date property

  1. Please do not do any Lucene searches (Alfresco no longer uses Lucene and the search language support is not being improved anymore) - stick to Alfresco FTS and/or CMIS
  2. You do not need to perform a search to find a node. The "search" root scope object has a simple findNode() operation which you can use with a NodeRef string value to lookup the node from the DB. You'd simply need to prefix your UUID with the workspace://SpacesStore/ fragment
  3. Does your JavaScript code complete successfully? E.g. is there some code after that section that may fail or are there messages in the log about a potential failure? The fact that the NodeBrowser shows a different value indicates that the value may not actually have been updated on the DB, which typically is a result of a transaction failing to commit.
sercama
Active Member II

Re: Update date property

Hi ,

Thank you for your reply. I've debug my code and I've found the problem. I've had an error in a behaviour, javascript code was properly.