cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to set primary classification attribute while creating part

jselvaraj
8-Gravel

How to set primary classification attribute while creating part

Hi All,

 

I am trying to create  a WTPart from java. In my set up the classification is set as a mandatory attribute.

 

Could you please help me on how to set  the value of the primary classification? I tried to set the default value for the classfication, however it does not work. Here is the code I am using to create WTPart.

 


   WTPart wtpart=WTPart.newWTPart();
   try {
    /
    TypeIdentifier typeidentifier = TypeHelper.getTypeIdentifier("WCTYPE|wt.part.WTPart");
    WCTypeIdentifier wctypeidentifier = (WCTypeIdentifier) typeidentifier;
    TypeDefinitionReference typeDefinitionReference = TypedUtilityServiceHelper.service.getTypeDefinitionReference(wctypeidentifier.getTypename());
    wtpart.setTypeDefinitionReference(typeDefinitionReference);
  
    wtpart.setName("Test part007");
    String container_path = "/wt.inf.container.OrgContainer=yyyy/wt.pdmlink.PDMLinkProduct=xxxx";
    WTContainerRef containerRef = WTContainerHelper.service .getByPath(container_path);
    wtpart.setContainerReference(containerRef);
    
    String folder_path = "/Default";
    Folder folder = FolderHelper.service .getFolder(folder_path,containerRef);
    FolderHelper. assignLocation(wtpart, folder);
    
    wtpart=(WTPart) wt.fc.PersistenceHelper.manager .store(wtpart);
    
    }

 

 

Thanks in advance.

3 REPLIES 3

Hi @jselvaraj,

Have you tried "How to set classification node or classification attributes value (available for 10.2 M030 and 11.0)" section of KB article CS217792?

 

WTPart part_work = (WTPart)WorkInProgressHelper.service.checkout(part, WorkInProgressHelper.service.getCheckoutFolder(), null).getWorkingCopy();
PersistableAdapter obj = new PersistableAdapter(part_work,null,SessionHelper.getLocale(), new UpdateOperationIdentifier());
obj.load(bindingAttributeName);
obj.set(bindingAttributeName,classificationNode);
obj.apply();
PersistenceHelper.manager.modify(part_work);
return (WTPart)WorkInProgressHelper.service.checkin(part_work, null);

 

Are you having some trouble doing it?

 

Thanks,

Shirish

I agree to use PersistableAdapter class to set the classification attribute value.

Hi selvaraj,

 

could you please provide me a import statement for  TypeHelper.getTypeIdentifier();

It would me more helpful for me.

Announcements

Top Tags