cancel
Showing results for 
Search instead for 
Did you mean: 

filing records via Web Scripts / JavaScript API

kgeis
Champ on-the-rise
Champ on-the-rise
I'm having problems writing a web script that can put some content into a RM folder.  I am basing my script on the example upload script.  Here's a snippet from my script:


  // find the appropriate record folder
  var filePlan = companyhome.childByNamePath("Sites/rm/documentlibrary");
  var recordFolder = filePlan.childByNamePath("Civilian Files/Case Files and Papers/Gilbert Competency Hearing");

  // create document in the record folder for uploaded file
  record = recordFolder.createFile(filename);
  record.properties.content.write(content);
  record.properties.encoding = "UTF-8";
  record.properties.title = title;
  record.properties.description = description;
  record.save();
Now, when I create a file in the record folder, RecordsManagementServiceImpl.onFileContent(..) is called by policy and the record aspects are added.  This is good.  However, when I go to view the created record in the node browser, the title and description are null.  I can't figure out how to set those in my script.

When I go to share and try to view the document, it bombs on the metadata form.  I guessed that some expected metadata was missing, and I found that the Share filed records have the "author" and "versionable" aspects in addition to what mine had.  So, I went to add the versionable aspect to my document by saying

record.addAspect("cm:versionable")
The effect of this is putting Alfresco into an infinite loop somewhere deep in its bowels.  If I'm "lucky" enough to use a database that does table locking, it just bombs after a timeout period.  (H2 bombs, H2 with MVCC enabled loops, PostgreSQL loops.)

I figured that I need to add the metadata in as similar a way to Share as possible, but I'm having a lot of trouble wrapping my head around the complexities of the implementation.

If Alfresco engineering reads this, please expose RM actions via the ScriptRecordsManagmentService.

Help would be appreciated.
2 REPLIES 2

kgeis
Champ on-the-rise
Champ on-the-rise
I'm wondering about whether Alfresco should call the "file" action upon TRANSACTION_COMMIT after adding record folder content.  It seems like this should be done for EVERY_EVENT.  How could I possibly set the record properties if the record aspect is not added until TRANSACTION_COMMIT (which I assume is outside the context of the web script, after the web script is done executing.)

fpp
Champ in-the-making
Champ in-the-making
There is a build in rule "Declare as record" you might be interested to have a look at. It can be applied to the folder where you upload the file to and might already do the job (and then check which other aspects are added).

Access is via the explorer client - create rule wizard.

Generally records can not have versions - you need to un-declare - re-declare them - same e.g. when filing emails with attachments - you need to spit them before declaring the file a record - otherwise you would change the file/record
(Updated) BUT- I just checked a photo record's aspects in the node browser - these show as following:
Aspects
{http://www.alfresco.org/model/system/1.0}referenceable
{http://www.alfresco.org/model/content/1.0}thumbnailed
{http://www.alfresco.org/model/content/1.0}titled
{http://www.alfresco.org/model/imap/1.0}flaggable
{http://www.alfresco.org/model/recordsmanagement/1.0}filePlanComponent
{http://www.alfresco.org/model/rmcustom/1.0}customSupplementalMarkingList
{http://www.alfresco.org/model/recordsmanagement/1.0}recordSearch
{http://www.alfresco.org/model/content/1.0}auditable
{http://www.alfresco.org/model/content/1.0}ownable
{http://www.alfresco.org/model/recordsmanagement/1.0}declaredRecord
{http://www.alfresco.org/model/recordsmanagement/1.0}record
{http://www.alfresco.org/model/dod5015/1.0}digitalPhotographRecord
{http://www.alfresco.org/model/recordsmanagement/1.0}commonRecordDetails
{http://www.alfresco.org/model/recordsmanagement/1.0}recordComponentIdentifier
{http://www.alfresco.org/model/content/1.0}versionable

Fpp