Fórum

Adding new phone number to organization

Roland Karlson, modificado 8 Anos atrás.

Adding new phone number to organization

New Member Postagens: 5 Data de Entrada: 10/03/16 Postagens Recentes
Hi I am trying to add new phone number to organisation
I am using following code

PhoneLocalServiceUtil.addPhone(userId, Organization.class.getName(), org.getOrganizationId(), number, "", officePhoneTypeId, true);

and I am getting following execption
om.liferay.portal.NoSuchListTypeException
at com.liferay.portal.service.impl.ListTypeServiceImpl.validate(ListTypeServiceImpl.java:59)
thumbnail
Anil Sunkari, modificado 8 Anos atrás.

RE: Adding new phone number to organization

Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
Hi Roland,

Could you please post the complete method which has the below line.

PhoneLocalServiceUtil.addPhone(userId, Organization.class.getName(), org.getOrganizationId(), number, "", officePhoneTypeId, true);

Thanks,
Anil Sunkari
Roland Karlson, modificado 8 Anos atrás.

RE: Adding new phone number to organization

New Member Postagens: 5 Data de Entrada: 10/03/16 Postagens Recentes
Yes sure

public void setPhone(Organization org, String number, Long userId) throws SystemException, PortalException {
List<Phone> phones = PhoneLocalServiceUtil.getPhones(org.getCompanyId(), Organization.class.getName(), org.getOrganizationId());
if (!phones.isEmpty() && phones.size() > 0) {
phones.get(0).setNumber(number);
} else {
List<ListType> phoneTypes = ListTypeServiceUtil
.getListTypes(Contact.class.getName()
+ ListTypeConstants.PHONE);
int officePhoneTypeId = 0;
for (ListType phoneType : phoneTypes) {
String phoneTypeName = phoneType.getName();
if ("business".equals(phoneTypeName)) {
officePhoneTypeId = phoneType.getListTypeId();
}
}

PhoneLocalServiceUtil.addPhone(userId, Organization.class.getName(), org.getOrganizationId(), number, "", officePhoneTypeId, true);
}
}
thumbnail
Anil Sunkari, modificado 8 Anos atrás.

RE: Adding new phone number to organization

Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
I think the mentioned method should return Phone Object.

Because Phone Interface has getType() function which is of List Type.

https://docs.liferay.com/portal/6.2/javadocs/com/liferay/portal/service/PhoneLocalServiceUtil.html#addPhone%28long,%20java.lang.String,%20long,%20java.lang.String,%20java.lang.String,%20int,%20boolean%29
Roland Karlson, modificado 8 Anos atrás.

RE: Adding new phone number to organization

New Member Postagens: 5 Data de Entrada: 10/03/16 Postagens Recentes
Sorry i don't understand how there return object is responsible for this exeption.

It seams that it cant find some type but...