Adding the custom field for the OOTB using the expando
Suppose if we think to add the custom field to the organization while creating the organization. here is the following code.
Organization organization = null;
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest. getAttribute (WebKeys.THEME_DISPLAY);
long userId = themeDisplay.getUserId();
try {
int statusId = ListTypeConstants.ORGANIZATION_STATUS_DEFAULT;
ServiceContext serviceContext = ServiceContextFactory. getInstance (Organization.class.getName(), renderRequest);
Map<String,Serializable> expandoBridgeAttributes = new HashMap<String, Serializable>();
expandoBridgeAttributes.put("test83", "Liferay");
Here "test83" is the field name of the custom attribute.
serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes);
OrganizationLocalServiceUtil. addOrganization(userId,0l, "name5",
"regular-organization", true, 0, 0, statusId, "comments", true, serviceContext);
System.out.println("dfdfdfdfdfdf"+organization.getExpandoBridge().getAttribute("test83"));
} catch (PortalException e) {
e.printStackTrace();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Comments
Post a Comment