AnsweredAssumed Answered

Aikau form to upload content with metadata

Question asked by mocaruru on Aug 27, 2017
Latest reply on Oct 2, 2018 by adelohb

Hi,

 

I would like to create a Aikau form that can upload a content with some metadata. When I tried to modify simple-page.get.js provided by alfresco sdk 3.0 like below,

 

 

var site = page.url.templateArgs.site;
var alfDestination = null;
var result = remote.call("slingshot/doclib/container/" + site + "/documentLibrary");
if(result.status.code == status.STATUS_OK){
   alfDestination = JSON.parse(result).container.nodeRef;

}


var formWidgets = [
{
   name: "alfresco/forms/controls/DojoValidationTextBox",
   config: {
      label: "Document No",
      name: "prop_xyz_docNo"
   }
},
{
   name: "alfresco/forms/controls/DojoValidationTextBox",
   config: {
      label: "Mandatory",
      name: "prop_xyz_mandatory"
   }
},
{
   name: "alfresco/forms/controls/DojoValidationTextBox",
   config: {
      label: "Action",
      name: "prop_xyz_action"
   }
},
{
   id : "FILE_SELECT",
   name: "alfresco/forms/controls/FileSelect",
   config:{
      label: "Upload File...",
      name: "uploadFile"
   }
}
];

 

//Create the form here
var form = {
   name: "alfresco/forms/Form",
   config: {
      showOkButton: true,
      okButtonLabel: "Save",
      showCancelButton: true,
      cancelButtonLabel: "Cancel",

      okButtonPublishTopic: "ALF_CRUD_CREATE",
      okButtonPublishGlobal: true,
      okButtonPublishPayload: {
         url: "sample/uploadTest",
         //To create the folder under document library, we need the documberLibrary nodeRer,So POST that too.
        alf_destination:alfDestination
},

widgets: formWidgets
}
};

//Add the form and services to the JSON MODEL
model.jsonModel = {
   widgets: [ form ],
   services: [
      "alfresco/services/CrudService",
      "alfresco/services/UploadService",
      "alfresco/services/DialogService",
      "alfresco/services/ActionService",
      "alfresco/services/DocumentService",
      "alfresco/services/SiteService",
      "alfresco/services/NotificationService"
   ]
};

 

After accessing the page, put the all fields and submit the data, got error in browser console,

 

Uncaught TypeError: Failed to construct 'File': 2 arguments required, but only 0 present.
at Object.clone (e919c032ca8754596233687dde088f8b.js:3155)
at clone (e919c032ca8754596233687dde088f8b.js:3146)
at Object._mixin (e919c032ca8754596233687dde088f8b.js:2731)
at Object.clone (e919c032ca8754596233687dde088f8b.js:3157)
at Object.alfresco_core_Core__alfCleanFrameworkAttributes [as alfCleanFrameworkAttributes] (e919c032ca8754596233687dde088f8b.js:12539)
at Object.alfresco_services_CrudService__clonePayload [as clonePayload] (e919c032ca8754596233687dde088f8b.js:30254)
at Object.alfresco_services_CrudService__onCreate [as onCreate] (e919c032ca8754596233687dde088f8b.js:30345)
at Evented.<anonymous> (e919c032ca8754596233687dde088f8b.js:3026)
at Evented.dispatcher [as onALF_CRUD_CREATE] (e919c032ca8754596233687dde088f8b.js:5192)
at Function.on.emit (e919c032ca8754596233687dde088f8b.js:6036)
clone @ e919c032ca8754596233687dde088f8b.js:3155
clone @ e919c032ca8754596233687dde088f8b.js:3146
_mixin @ e919c032ca8754596233687dde088f8b.js:2731
clone @ e919c032ca8754596233687dde088f8b.js:3157
alfresco_core_Core__alfCleanFrameworkAttributes @ e919c032ca8754596233687dde088f8b.js:12539
alfresco_services_CrudService__clonePayload @ e919c032ca8754596233687dde088f8b.js:30254
alfresco_services_CrudService__onCreate @ e919c032ca8754596233687dde088f8b.js:30345
(anonymous) @ e919c032ca8754596233687dde088f8b.js:3026
dispatcher @ e919c032ca8754596233687dde088f8b.js:5192
on.emit @ e919c032ca8754596233687dde088f8b.js:6036
on.emit @ e919c032ca8754596233687dde088f8b.js:6077
emit @ e919c032ca8754596233687dde088f8b.js:6362
publish @ e919c032ca8754596233687dde088f8b.js:6315
alfresco_core_PubQueue__publish @ e919c032ca8754596233687dde088f8b.js:13882
(anonymous) @ e919c032ca8754596233687dde088f8b.js:12647
forEach @ e919c032ca8754596233687dde088f8b.js:3588
alfresco_core_Core__alfPublish @ e919c032ca8754596233687dde088f8b.js:12600
alfresco_buttons_AlfButton__onClick @ e919c032ca8754596233687dde088f8b.js:35430
_onClick @ e919c032ca8754596233687dde088f8b.js:35949
(anonymous) @ e919c032ca8754596233687dde088f8b.js:3024
__onClick @ e919c032ca8754596233687dde088f8b.js:35936
(anonymous) @ e919c032ca8754596233687dde088f8b.js:3024
on.emit @ e919c032ca8754596233687dde088f8b.js:6075
(anonymous) @ touch.js:172
setTimeout (async)
(anonymous) @ touch.js:171

 

I thought I needed to pass some parameter before publishing ALF_CRUD_CREATE but don't know how.

Outcomes