Create new Serie using Javascript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2011 04:26 AM
Hello,
I'm trying to create a new record series in the Javascript console for testing purposes (later I want to use it in a web script).
The series gets created, but the problem is that I can't create new categories inside the series I've created (the "New Category" button is disabled).
Anyone knows what I'm missing?
Thanks,
Jordi.
I'm trying to create a new record series in the Javascript console for testing purposes (later I want to use it in a web script).
The series gets created, but the problem is that I can't create new categories inside the series I've created (the "New Category" button is disabled).
var filePlan = companyhome.childByNamePath(space.name + "/rm/documentLibrary");var series = filePlan.children;var newSeries = filePlan.createFolder("Test folder");newSeries.addAspect("{http://www.alfresco.org/model/rmcustom/1.0}customRecordSeriesProperties");newSeries.addAspect("{http://www.alfresco.org/model/content/1.0}titled");newSeries.addAspect("{http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent");newSeries.addAspect("{http://www.alfresco.org/model/recordsmanagement/1.0}recordComponentIdentifier");
Anyone knows what I'm missing?
Thanks,
Jordi.
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2011 07:13 AM
It seems that I've found a workaround to my problem, based on this post.
Rather than creating a new folder, I copy an existing record series and then I change it's name and metadata:
If there's a better way to do this or someone knows why the code from my first post doesn't work feel free to reply.
Cheers,
Jordi.
Rather than creating a new folder, I copy an existing record series and then I change it's name and metadata:
var filePlan = companyhome.childByNamePath(space.name + "/rm/documentLibrary");var series = filePlan.children;var templateSeries = series[0];if (templateSeries != null) { var newSeries = templateSeries.copy(filePlan, false); newSeries.name = "Test folder";}
If there's a better way to do this or someone knows why the code from my first post doesn't work feel free to reply.
Cheers,
Jordi.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2011 09:52 AM
Hi,
You are wrong because it's not a cm:folder node, It's dod:recordSeries node.
Behind you can find a snippet to do what you except.
Hope it helps
You are wrong because it's not a cm:folder node, It's dod:recordSeries node.
Behind you can find a snippet to do what you except.
var filePlan = companyhome.childByNamePath("Sites/rm/documentLibrary");if (filePlan != undefined){ var testSerie = createSeries(filePlan, "S123456");}function createSeries(folder, name){ if (folder.childByNamePath(name) != undefined){ return folder.childByNamePath(name); } var series = folder.createNode(name, "dod:recordSeries"); series.addAspect("rma:filePlanComponent"); //Unique Identifier var props = new Array(1); props["rma:identifier"] = createUniqueIdentifier(series); series.addAspect("rma:recordComponentIdentifier", props); return series;}function createUniqueIdentifier(serieNode){ //Unique Identifier var d = new Date(); var year = d.getFullYear(); var dbid = serieNode.properties["sys:node-dbid"] + ""; var recordId = year + "-" + padString(dbid, 10); return recordId;}//Create Unique Identifierfunction padString(s, len){ var result = s; for (i = 0; i < (len - s.length); i++){ result = "0" + result; } return result;}
Hope it helps
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2011 10:07 AM
Thanks a lot, it works like a charm!
Cheers,
Jordi.

Cheers,
Jordi.
