Is there a way to change nodeType of a document

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

Is there a way to change nodeType of a document

Hi,

is there any API service that i can call to change nodeType of a document.

 

Thanks for reading, hope someone has the answer!

1 Reply
Moderator
Moderator

Re: Is there a way to change nodeType of a document

There is an action to change the type OOTB in share: 

https://docs.alfresco.com/6.0/tasks/library-item-change-type.html

It calls a repository webscript: Document List Component - type submit at "/slingshot/doclib/type/node/{store_type}/{store_id}/{id}" url.

If you want to change the type via rest call, you can utilize above given webscript. This webscript can change the type from cm:content to custom content type you have created.

e.g.:

<type name="cm:content">
	<!-- Custom sub-type added for whitepapers -->
	<subtype name="my:whitepaper" />
</type>

but if you want to change the type between two custom content types then it will not work. You can customize the above webscript to handle this case. 

e.g.:

<type name="my:whitepapper">
	<subtype name="my:relatedwhitepaper" />
</type>

Here is the webscript definition:

type.post.desc.xml

<webscript> <shortname>type</shortname> <description>Document List Component - type submit</description> <url>/slingshot/doclib/type/node/{store_type}/{store_id}/{id}</url> <format default="json">argument</format> <authentication>user</authentication> <transaction>required</transaction> <lifecycle>internal</lifecycle> </webscript>

In custom webscript, you can get the targetType and build the nodeRef based on "store_type, store_id and Id" and use NodeService to set the type. All the required input will be available in json payload sent to the webscript on change Type action.

You can find an example here: https://javaworld-abhinav.blogspot.com/2020/06/change-type-of-custom-content-types.html

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)