Create a Record
- Sevia Kyriacou (Deactivated)
- Former user (Deleted)
- Vasilis Kleanthous (Unlicensed)
Owned by Sevia Kyriacou (Deactivated)
This section describes how a new record is created.
Â
What does this section cover?
Create a Record
In the following example, a contact information record is created. To construct the new object, construct() of CRMBOContactInformationBean is used. Afterwards, various objects, mandatory and optional, are set to the contact information object. Finally, the new contact information record is validated and saved.
createContact Expand source
@EJB private CRMBOContactInformationBean contactInformationBean; @EJB private CRMBOContactInfoEmailBean contactInfoEmailBean; @EJB private CRMBOContactInfoAddressBean contactInfoAddressBean; public CRMDOContactInformation createContact(String firstName, String lastName, String streetName, String streetNumber,String emailAddress) throws Exception{ //Create the contact Information creation data object and define the contact fields CRMDOContactInformation contactInformation = (CRMDOContactInformation)contactInformationBean.construct(); //Define PERSON as default type of contact information object and parse the parameters in the object contactInformation.setType(ContactInformationType.PERSON); contactInformation.setFirstName(firstName); contactInformation.setLastName(lastName); //Declare a collection of contact information addresses Set<CRMDOContactInfoAddress> addresses = new HashSet<CRMDOContactInfoAddress>(); //Create the address data object and define the address fields CRMDOContactInfoAddress address = (CRMDOContactInfoAddress)contactInfoAddressBean.construct(contactInformation); //Define HOME as default type of contact information address object and parse the parameters in the object address.setType(AddressTypes.HOME); address.setStreetName(streetName); address.setStreetNumber(streetNumber); //Add the address record in contact information address collection and then add the addresses in the contact information object addresses.add(address); contactInformation.setAddresses(addresses); //Declare a collection of contact information emails Set<CRMDOContactInfoEmail> emailAddresses =new HashSet<CRMDOContactInfoEmail>(); //Create the email data object and define the email fields CRMDOContactInfoEmail email=(CRMDOContactInfoEmail)contactInfoEmailBean.construct(contactInformation); //Define PERSONAL as default type of contact information email object and parse the parameters in the object email.setType(EmailTypes.PERSONAL); email.setAddress(emailAddress); //Add the email record in contact information email collection and then add the email addresses in the contact information object emailAddresses.add(email); contactInformation.setEmails(emailAddresses); //Validate and save the contact information contactInformation = (CRMDOContactInformation)contactInformationBean.validateAndSave(contactInformation); return contactInformation; }