Adding address for Organization


1.Adding Address

List<ListType> addressTypes = ListTypeServiceUtil.getListTypes(Organization.class.getName()+ ListTypeConstants.ADDRESS);
Here retrieving the all the address for the organization. Below screen is the available address for the organization. (1.Billing, 2.Other, 3.P.O.Box, 4.Shipping) .Hence "addressTypes" contains all these address
As an example we will add address as "Billing" type. so we will iterate all for the listtypes to get Billing type.
for (ListType addressType : addressTypes) {
String addressTypeName = addressType.getName();
if(addressTypeName.equalsIgnoreCase("Billing")) {
personalAddressTypeId = addressType.getListTypeId();
}
}
Then adding the adddress

AddressLocalServiceUtil.addAddress(userId, Organization.class.getName(), organization.getOrganizationId(), street1, street2, street3, city, zip,regionId, countryId, personalAddressTypeId, true, true);

Here we need to add the country and region also, we can retrieve country as      
Country country = CountryServiceUtil.getCountryByName("India");
In method last 2 parameter's true are "mailing, primary" We can observe these entries in the above screen shot as checkbox and radiobutton. Since we have given true for the both entries the values will be checked.

Comments

Popular posts from this blog

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate

Opening portlet in popup