How to create subtype of WTDocument by API?
We can use API to create new WTDocument, but we have a subtype under WTDocument, how can I create a subtype by API? Who could help me? Thanks in advanced.
We can use API to create new WTDocument, but we have a subtype under WTDocument, how can I create a subtype by API? Who could help me? Thanks in advanced.
@WhiteChen wrote:
We can use API to create new WTDocument, but we have a subtype under WTDocument, how can I create a subtype by API? Who could help me? Thanks in advanced.
I know of 2 ways to do this. Method 1 where you find the TypeDefinitionReference and set the doc type and method 2 by using the PersistableAdapter.
Method 1:
//find the TypeIdentifier
TypeIdentifier myCustomType = TypeHelper.getTypeIdentifier("WCTYPE|wt.doc.WTDocument|com.mydomain.Document.myCustom");
//cast to WCTypeIdentifier
WCTypeIdentifier myCustomWCType = (WCTypeIdentifier) myCustomType;
//find the TypeDefinitionReference
TypeDefinitionReference myCustomTDR = TypedUtilityServiceHelper.service.getTypeDefinitionReference(myCustomWCType.getTypename());
//create doc
WTDocument doc = WTDocument.newWTDocument();
//set the doc TypeDefinitionReference
doc.setTypeDefinitionReference(myCustomTDR);
Method 2:
//Use the PersistableAdapter
PersistableAdapter obj = new PersistableAdapter("com.mydomain.Document.myCustom", locale, new CreateOperationIdentifier());
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.