Searching entities through custom attribute value.

Sushil Patidar
Sushil Patidar
Lectura de menos de un minuto

If you need to search Users who has particular custom attribute value .Using liferay expando API ,this can be acheived easly as follows.

String attrValue ="IT";
 
String attributeName ="user-department-name";
 
String tableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
 
long classNameId = ClassNameLocalServiceUtil.getClassNameId(User.class);
 
 
List<ExpandoValue> expandoValues =ExpandoValueLocalServiceUtil.getColumnValues(companyId, classNameId, tableName, attributeName, attrValue, -1,-1);
 
 
for(ExpandoValue expandoValue:expandoValues)
 
  try {
      long userId = expandoValue.getClassPK();
      User user  =UserLocalServiceUtil.getUser(userId);
  }
  catch(NoSuchUserException nsue) {
 
   _log.error("No Such User Exist");
  }
}
 

 

Comentarios de la página

Related Assets...

No se encontraron resultados

More Blog Entries...

Ben Turner
abril 29, 2026
Ben Turner
abril 29, 2026