Search code examples
javascriptalfrescoalfresco-sharealfresco-webscripts

Alfresco Dictionary add a lot of data using javascript


I have a dictionary nodeRef that i know. I need to fill this dictionary with a lot of values, this values have to be imported by hand or using javascript console. Is there a way using javascript console to import this values? For example:

var firstArray = ['a','b','c'];
var secondArray =['1','2','3'];
var dict = search.findNode("workspace://SpacesStore/9f3291b8-9733-45bd-8537-7c2e8a18cd2a");
...
...

Thank's in advance.


Solution

  • If you are using JS console as a add on, then you can use the below scripts to import noderef and acp.

    Ref: https://gist.github.com/CesarCapillas/6f7692a1d657ce43851598ca9d5ecaa1

    Import a script from the repository using a name-based path: 
    
    <import resource="/Company Home/Data Dictionary/Scripts/library.js">
    
    Import a script from the repository using a NodeRef reference: 
    
    <import resource="workspace://SpacesStore/6f73de1b-d3b4-11db-80cb-112e6c2ea048">
    
    Import a script from a Java classpath location: 
    
    <import resource="classpath:alfresco/extension/myutils.js"> 
    
    // Import ACP  
    var targetNodeForImport = companyhome.childByNamePath("Sites/swsdp2/documentLibrary");  
    var ACPFile = companyhome.childByNamePath("ACPexport.acp");  
    var importAction = actions.create("import");  
    importAction.parameters.encoding = "UTF-8";  
    importAction.parameters.destination = targetNodeForImport;  
    importAction.execute(ACPFile);