cancel
Showing results for 
Search instead for 
Did you mean: 

How to change content type?

jcustovic
Champ in-the-making
Champ in-the-making
I can set custom content type when I create node for the first time, but how can I change it afterwards?

My code for setting content type:
String contentType = "{customNamespace}customLocalName";
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, contentType, properties);
3 REPLIES 3

openpj
Elite Collaborator
Elite Collaborator
You have to use the ActionService and you have to execute the specialise-type action with a parameter for the target type:

Action action = new Action();
action.setActionName("specialise-type");
NamedValue[] actionParameters = new NamedValue[]{new NamedValue("type-name", false, "YOUR_CUSTOM_CONTENT_TYPE", null)};
action.setParameters(actionParameters);
WebServiceFactory.getActionService().executeActions(predicate, new Action[]{action});
Hope this helps.

jcustovic
Champ in-the-making
Champ in-the-making
Tnx! Works like a charm…

nguyenhoathuan
Champ in-the-making
Champ in-the-making
You have to use the ActionService and you have to execute the specialise-type action with a parameter for the target type:

Action action = new Action();
action.setActionName("specialise-type");
NamedValue[] actionParameters = new NamedValue[]{new NamedValue("type-name", false, "YOUR_CUSTOM_CONTENT_TYPE", null)};
action.setParameters(actionParameters);
WebServiceFactory.getActionService().executeActions(predicate, new Action[]{action});
Hope this helps.
Hi OpenPj and every body, as I know YOUR_CUSTOM_CONTENT_TYPE is the string value of variable, with name of this variable is type-name in our action. Am i right ?
So, if type-name is noderef type(example in mail action), how i set value for it ?
I really disturbed.
Sorry if my question botthers you !