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.
The error message does not point to an error in your JSON - it displays a problem with a core Aikau function (alfresco_core_Core__alfCleanFrameworkAttributes) when used together with native data structures (in this case a File object). It stands to reason thatthe AlfCrudService itself cannot handle form data that includes files. Aikau has a special service for handling file updloads, the UploadService, though that service cannot handle metadata. For your requested interaction it might be necessary to create a composition of the regular Crud and the Upload service, and use a cutom service to handle the pubSub-flow, i.e. by processing the upload first and then immediately post the update of the metadata.
Unfortunately, that is not something you can do by simple configuration in the JSON model - you will have to write Aikau client-side JavaScript for this.
Yoshihiko Aochi I had the same problem I would be grateful if you told me if you have any answer to that
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.