Error when saving document of custom type in Alfresco Share - alfresco

I got this exception when trying to save a new document of custom type:
org.alfresco.service.cmr.repository.MalformedNodeRefException: 06010026 Invalid node ref - does not contain forward slash: {node.nodeRef}
Here is how the definition of the custom type looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="ht:channelmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Imports are required to allow references to definitions in other models
-->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="http://www.someco.com/model/content/1.0" prefix="ht" />
</namespaces>
<types>
<!-- Here comes my type -->
<type name="ht:doc">
<title>Custom Document</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>cm:generalclassifiable</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<aspect name="ht:channel">
<title>Content Channel</title>
<properties>
<property name="ht:isWeb">
<type>d:boolean</type>
</property>
</properties>
</aspect>
</aspects>
</model>
and here is how I set the forms for displaying the creation of a new document of my custom type (inside share-config-custom.xml)
<alfresco-config>
<config evaluator="string-compare" condition="DocumentLibrary">
<create-content>
<content id="plain-text" mimetype="text/plain" label="Prompt" itemid="ht:doc" />
</create-content>
<aspects>
<visible>
<aspect name="ht:channel" />
</visible>
<addable>
</addable>
<removeable>
</removeable>
</aspects>
<types>
<type name="cm:content">
<subtype name="ht:doc" />
</type>
</types>
</config>
<config evaluator="model-type" condition="ht:doc">
<forms>
<form>
<field-visibility>
<show id="cm:title" force="true" />
<show id="ht:isWeb" force="true" />
</field-visibility>
<appearance>
<field id="cm:title">
<control template="/org/alfresco/components/form/controls/textfield.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
</alfresco-config>
Is it something wrong with the formatting or am I missing some fields in the type definition?
Thanks

Found the solution on the dedicated Alfresco forum.
Here it is:
<content id="myContent" label="Prompt" type="pagelink" index="1" >
<param name="page">create-content?destination={nodeRef}&itemId=ht:doc&mimeType=text/html</param>
</content>

Related

Can't import content model with types associations

I use Alfresco Community - 7.2.0 (rf6d005c1-blocal). When I try to import content model with types associations I get the error: "special model does not support element 'associations'".
I have created very simple model to test. If tag 'associations' is commented then all is ok. I wonder what's wrong?
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="cm_test:contentmodel_test"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>Alfresco Content Domain Model TEST</description>
<author>Test</author>
<published>2022-06-29</published>
<version>1.10</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco_test.org/model/content_test/1.10" prefix="cm_test"/>
</namespaces>
<types>
<type name="cm_test:authority_test">
<title>Alfresco Authority Abstract Type</title>
<parent>sys:base</parent>
</type>
<type name="cm_test:zone_test">
<title>Alfresco Authentication Zone Type</title>
<parent>cm:cmobject</parent>
<properties>
</properties>
<associations>
<child-association name="cm_test:inZone_test">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm_test:authority_test</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
</child-association>
</associations>
</type>
</types>
</model>

Unable to change type of document in alfresco share

I have two questions about two Custom Content Types I created called my:whitepaper and my:bc:
When I try to Change Type on a document and I select my:whitepaper custom type it works but not with my:bc.
When I select my:bc It gives me an error message saying: Unable to change type of document 'test.pdf'.
In "Manage Rules" -> "Specialse Type" , I can't see my bc type:
The type of 'test.pdf' document is cm:content:
Here's my :
custom-model-context.xml:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/customModel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco/extension/custom-model-messages</value>
</list>
</property>
</bean>
</beans>
custom-model-messages.properties:
type.my_whitepaper= piece Comptable
type.my_whitepaper.title= piece Comptable
type.my_whitepaper.property.my_product= Ecriture Comptable
type.my_bc=bc
type.my_bc.title=bc
customModel.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<!-- The important part here is the name - Note: the use of the my: namespace
which is defined further on in the document -->
<model name="my:contentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Example Custom Model</description>
<author>Alfresco Documentation Team</author>
<version>1.0</version>
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0"
prefix="d" />
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>
<!-- Introduction of new namespaces defined by this model -->
<!-- NOTE: The following namespace my.new.model should be changed to reflect
your own namespace -->
<namespaces>
<namespace uri="http://www.mycompany.com/model/content/1.0" prefix="my" />
</namespaces>
<types>
<!-- Enterprise-wide generic document type -->
<type name="my:doc">
<title>MyCompany Generic Document</title>
<parent>cm:content</parent>
</type>
<type name="my:marketingDoc">
<title>MyCompany Marketing Document</title>
<parent>my:doc</parent>
<properties>
<property name="my:product">
<title>écriture comptable</title>
<type>d:text</type>
</property>
<property name="cm:author">
<title>auteur</title>
<type>d:text</type>
</property>
</properties>
</type>
<type name="my:bc">
<title>Bon de commande</title>
<parent>my:marketingDoc</parent>
</type>
<type name="my:whitepaper">
<title>une piece Comptable</title>
<parent>my:marketingDoc</parent>
</type>
</types>
</model>
share-config-custom.xml:
<types>
<type name="cm:content">
<subtype name="smf:smartFolderTemplate" />
<subtype name="my:whitepaper" />
<subtype name="my:bc" />
</type>
<type name="cm:folder">
</type>
<type name="trx:transferTarget">
<subtype name="trx:fileTransferTarget" />
</type>
</types>
<!-- custom content comptable -->
<config evaluator="model-type" condition="my:whitepaper">
<forms>
<form>
<field-visibility>
<show id="cm:name" />
<show id="my:product" />
<show id="cm:author" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<!-- <show id="my:relatedDocuments" />-->
</field-visibility>
</form>
</forms>
</config>
<config evaluator="node-type" condition="my:whitepaper">
<forms>
<form>
<field-visibility>
<show id="cm:name" />
<show id="my:product" />
<show id="cm:author" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<!-- <show id="my:relatedDocuments" /> -->
</field-visibility>
</form>
</forms>
</config>
<!-- custom Bon commande -->
<config evaluator="model-type" condition="my:bc">
<forms>
<form>
<field-visibility>
<show id="cm:name" />
<show id="my:product" />
<show id="cm:author" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<!-- <show id="my:relatedDocuments" />-->
</field-visibility>
</form>
</forms>
</config>
<config evaluator="node-type" condition="my:bc">
<forms>
<form>
<field-visibility>
<show id="cm:name" />
<show id="my:product" />
<show id="cm:author" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<!-- <show id="my:relatedDocuments" /> -->
</field-visibility>
</form>
</forms>
</config>
Logs:
The logs : alfresco.log and catalina.out don't show anything.
Browser's Developer tools show this:
I am unable to reproduce this problem in a project generated with SDK 3.0.1, taking all defaults (Repo 5.2.f/Share 5.2.e) with your content model and Share config. I can change cm:content objects to my:bc objects. When configuring rules I can select your custom types in the Specialize Type action, see screenshot, below:.
So, either you have some other stuff added to your config that hasn't been included in the above snippets or you haven't deployed your customizations correctly.
You might want to bootstrap a new project and drop your files in as I have, then run it with the embedded Tomcat to make sure you can change types and configure rules successfully. Then you can compare what is in that project to what you have in your original project to see where you went wrong.

Alfresco custom subtypes for cm:folder not working

I tried to to create a new folder type, that inherits everything from cm:folder, so I created an xml file for myModel.xml under tomcat/shared/classes/alfresco/extension/models, and added the following content to it:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="my:custmodel"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>custom folder test</description>
<author>Max Mustermann</author>
<published>2015-11-24</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<namespace uri="http://www.alfresco.org/model/rendition/1.0" prefix="rn"/>
<namespace uri="http://www.alfresco.org/model/exif/1.0" prefix="exif"/>
<namespace uri="http://www.alfresco.org/model/audio/1.0" prefix="audio"/>
<namespace uri="http://www.alfresco.org/model/webdav/1.0" prefix="webdav"/>
<namespace uri="http://www.example.com/model/content/1.0" prefix="my" />
</namespaces>
<types>
<type name="my:folder1">
<title>folder1</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
<type name="my:folder2">
<title>folder2</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
</types>
then I added the following line to tomcat/shared/classes/alfresco/extension/custom-model-context.xml
<value>alfresco/extension/models/myModel.xml</value>
and finally in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:
<type name="cm:folder">
<subtype name="my:folder1" />
<subtype name="my:folder2" />
</type>
Now the under details->change Typ, my subtypes appear, but when I try to apply them I get "cannot change type of document ..."
Your model file name in context file is mentioned as
<value>alfresco/extension/models/custModel.xml</value>
in your description you are saying name as "myModel.xml" is that a typo? Otherwise your file entries looks okey. Hope you are placing those entries properly.
This entry
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
should be part of <imports> tag not <namespaces>
Something like this
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

Date Search in AdvancedSearch functionality : Alfresco

I tried advanced search functionality in alfresco. I couldn't search data with date condition..
I can search using other fields..but not with date criteria.
How can I search data with date field.
Following is my custom model
share-config-custom.xml
<config evaluator="model-type" condition="my:test">
<forms>
<form id="search">
<field-visibility>
<show id="my:corDate" />
</field-visibility>
<appearance>
<field id="my:corDate">
<control template="/org/alfresco/components/form/controls/date.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
datatype of my:corDate d:date
following is advanced search code
<config replace="true" evaluator="string-compare" condition="AdvancedSearch">
<advanced-search>
<forms>
<form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
<form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>
<form labelId="type.my_test" descriptionId="search.form.desc.my_test">my:test</form>
</forms>
</advanced-search>
</config>
customModel.xml
<type name="my:test">
<title>Test</title>
<parent>cm:content</parent>
<properties>
<property name="my:corDate">
<title>Correspondence Date</title>
<type>d:date</type>
<mandatory>true</mandatory>
<index enabled="true">
<atomic>true</atomic>
<stored>true</stored>
<tokenised>both</tokenised>
</index>
</property>
</properties>
</type>
How can I solve this problem..How can I do search with date criteria ?
Thanks

Alfresco share advanced search

I have some problem. I am create custom model ed:edocumentswith one aspect ed:zagdep it has one property ed:documentRegnum.
I am customize Advanced Search Form and add RegNum field, but it does not search nothing with this field.
What it can be? Why search does not work?
My model code ed-model.xml (tomcat\shared\classes\alfresco\extension)
<?xml version="1.0" encoding="UTF-8"?>
<model name="ed:edocuments" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="http://www.alfresco.com/model/edocuments/1.0" prefix="ed"/>
</namespaces>
<aspects>
<!-- Definition of new Content Aspect: Electronic Document -->
<aspect name="ed:zagdep">
<title>Zag Dep</title>
<properties>
<property name="ed:documentRegnum">
<type>d:text</type>
</property>
</properties>
</aspect>
</aspects>
</model>
My model contex file ed-model-contex.xml (tomcat\shared\classes\alfresco\extension)
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="extension.ed.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/ed-model.xml</value>
</list>
</property>
</bean>
</beans>
My share-config-custom.xml(tomcat\shared\classes\alfresco\web-extension)
<alfresco-config>
<!-- Document Library config section -->
<config evaluator="string-compare" condition="DocumentLibrary">
<aspects>
<!-- Aspects that a user can see -->
<visible>
<aspect name="cm:generalclassifiable" />
<aspect name="cm:complianceable" />
<aspect name="cm:dublincore" />
<aspect name="cm:effectivity" />
<aspect name="cm:summarizable" />
<aspect name="cm:versionable" />
<aspect name="cm:templatable" />
<aspect name="cm:emailed" />
<aspect name="emailserver:aliasable" />
<aspect name="cm:taggable" />
<aspect name="app:inlineeditable" />
<aspect name="kb:referencable" />
<aspect name="ed:zagdep" />
</visible>
<!-- Aspects that a user can add. Same as "visible" if left empty -->
<addable>
</addable>
<!-- Aspects that a user can remove. Same as "visible" if left empty -->
<removeable>
</removeable>
</aspects>
</config>
<!-- cm:content type (existing nodes) -->
<config evaluator="node-type" condition="cm:content">
<forms>
<!-- Default form configuration used on the document details and edit metadata pages -->
<form>
<field-visibility>
<show id="ed:documentRegnum" />
</field-visibility>
</form>
<!-- Document Library pop-up Edit Metadata form -->
<form id="doclib-simple-metadata">
<field-visibility>
<show id="ed:documentRegnum" />
</field-visibility>
<edit-form template="../documentlibrary/forms/doclib-simple-metadata.ftl" />
</form>
<!-- Document Library Inline Edit form -->
<form id="doclib-inline-edit">
<field-visibility>
<show id="ed:documentRegnum" />
</field-visibility>
</form>
</forms>
</config>
<!-- Advanced search -->
<config replace="true" evaluator="string-compare" condition="AdvancedSearch">
<advanced-search>
<!-- Forms for the advanced search type list -->
<forms>
<form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
<form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>
</forms>
</advanced-search>
</config>
<config evaluator="model-type" condition="cm:content">
<forms>
<!-- Search form -->
<form id="search">
<field-visibility>
<show id="cm:name" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<!-- ed:edocuments -->
<show id="ed:documentRegnum" />
</field-visibility>
<appearance>
<!-- ed:edocuments -->
<field id="ed:documentRegnum" label-id="prop.ed_documentRegnum">
<control template="/org/alfresco/components/form/controls/textfield.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
</alfresco-config>
You just have to add : force="true" on aspect based property.See below code.
<show id="ed:documentRegnum" force="true" />

Resources