Hi,
is there any API service that i can call to change nodeType of a document.
Thanks for reading, hope someone has the answer!
Solved! Go to Solution.
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
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
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.