cancel
Showing results for 
Search instead for 
Did you mean: 

How to append the creator and create-time to a file name automatically.

andy2_0
Champ in-the-making
Champ in-the-making
I hope to append the creator and "create time" to a file name while I create a document from a template.
For example:
template name: reimbursement-record.xls
After the file created, file name changed to: reimbursement-record-Smith-20140214.xls

Wonder if there is an easy way?

Thanks in advance!



4 REPLIES 4

niketapatel
Star Contributor
Star Contributor
Hi Andy, you can do it by either custom behaviour or by executing custom js as a rule on folder when particular type of content gets added.

Please check below forum, in which document version is being appended in document name, same way you can get document creator and created date.
http://forums.alfresco.com/comment/141879#comment-141879

Hope it helps!

Hi
For rule,At first,I have writen a XXX.js,Second executes the custom javascript on content update,but it doesn't work,could you tell me why? is there something wrong in the XXX.js?
Thanks in advances!
the XXX.js code as following:

var versionHistory = document.versionHistory;

if (versionHistory != null)
{
  var version = versionHistory[0];
  var creator = version.creator;
  var createdDate = version.createdDate;
  document.name = document.name +"-"+ creator +"-"+ createdDate;
  document.save();
}

mrogers
Star Contributor
Star Contributor
The version history probably does not exist.   Why aren't you using the auditable aspect of the document itself?

rock_tu
Champ on-the-rise
Champ on-the-rise
Hi
At first,thanks for your solution and I have writen code like this,but is still doesn't work,could you tell me where is error?
Thank you very mush!
this code as following like this
var aspects = document.aspects;
for(s in aspects){
   if(s!=null && s=="auditable"){
      document.name += s.properties.creator;
      document.name += s.properties.created;
      break;
   }
}
document.save();