If you want to set the primary category of an object, you can use the EnterpriseEntity.setPrimaryCategory() method. The following code sample provides an example of how to create a new contact and set its primary category:
// Retrieve the contact service ContactService contactService = platform.getContactService();
// Create a new, blank contact. The vendor record is a contact which has // previously been created. Set some categories for the contact record Contact contact = contactService.newCompany("vendor"); contact.setPrimaryCategory("CONT_EXTE_LAWF"); contact.addCategory("CONT_EXTE_VEND");
// Save the contact to the database contactService.create(contact); |
If you want to return the primary category of an object, you can use the EnterpriseEntity.getPrimaryCategory() method. The following code sample returns the primary category of a contact:
Category primaryCategory = contact.getPrimaryCategory(); |
For a complete sample, see the Checking the Default Role in Related Involved Records sample.