Create Node with custom properties

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member II

Create Node with custom properties

Hi,

I need to create custom properties when I upload file :

 

const opts = {
name: media.name,
nodeType: 'cm:content',
include: ['allowableOperations'],
renditions: 'doclib'
};
const nodeBody = {
properties: {
'cm:title': media.name,
'mj:custom1': 'value1',
'mj:custom2': 'value2'
}
};
return this.uploadsApi.uploadFile(file, '', this.documentLibraryNode, nodeBody, opts);

But I get this error:

Error: {"error":{"errorKey":"mj:custom1 isn't a valid QName. Namespace prefix mj is not mapped to a namespace URI","statusCode":400,"briefSummary":"10200018 mj:custom1 isn't a valid QName. Namespace prefix mj is not mapped to a namespace

Does-it mean I need to add xml file to tomcat/webapp/alfresco or share repository or something like this ?

Or can I resolve it with alfresco-js-api (adf) ?

How does-it-work ?

Thank you a lot in advance

 

2 Replies
Highlighted
Intermediate

Re: Create Node with custom properties

Hi,

If not already done, then you need to define a custom content model in XML and then bootstrap / load into the Content Repository, either statically or dynamically.

https://docs.alfresco.com/community/concepts/content-model-deploy.html

https://docs.alfresco.com/community/concepts/admintools-cmm-intro.html

If you already have a custom model then please add it here with any additional boostrap config files (if you're loading statically).

Regards,

Jan

Highlighted
Moderator
Moderator

Re: Create Node with custom properties

In addition, i would also recommend you to go through these tutorials. This turotial would provide you a better understanding on working with custom models. https://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html

Full series: 

https://ecmarchitect.com/alfresco-developer-series

https://docs.alfresco.com/6.1/references/dev-extension-points-content-model.html