Monday 19 September 2016

Expando Values.

Get the custom attribute values or Expando values :
======================================

User user = null;
ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
user = themeDisplay.getUser();
long curLoginUserid = user.getUserId();
ExpandoValue expandoMobileNumberValue =  ExpandoValueLocalServiceUtil.getValue(themeDisplay.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, "contact-number-mobile", curLoginUserid);
ExpandoValue expandoUserCountryValue =  ExpandoValueLocalServiceUtil.getValue(themeDisplay.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, "User Country", curLoginUserid);
String curLoginMobileNumber = expandoMobileNumberValue.getData();
String curLoginUserCountry = " ";
if(Validator.isNotNull(expandoUserCountryValue))
curLoginUserCountry = expandoUserCountryValue.getData();

Update expando values of login user:
============================

ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
User loginUser = themeDisplay.getUser();
User user = null;
ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
user = themeDisplay.getUser();
long curLoginUserid = user.getUserId();
String updateCompanyName = UpdateForm.getCompanyName();
ExpandoValue expandoValue =  ExpandoValueLocalServiceUtil.getValue(themeDisplay.getCompanyId(), User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, "company-name", userId);
expandoValue.setData(updateCompanyName);
ExpandoValueLocalServiceUtil.updateExpandoValue(expandoValue);

No comments:

Post a Comment

  Inter Portlet Communication (IPC) in Liferay 7.4 Public Render Parameter IPC: 1) Create a new module project -> SenderPortlet 2) In  Se...