Liferay
is providing the following remote service com.liferay.portlet.expando.service.impl.ExpandoValueServiceImpl which can be used
for adding/selecting/updating the custom field data.
Here
are the parameters to be passed in:
1. CompanyId:
company id that is assigned
2. Class
Name: The entity name that we have created the custom attribute for
3. TableName:
Is always CUSTOM_FIELDS
4. ColumnName:
The name given for the attribute
5. classPK:
Primary key value within the entity.
6. Data:
the value to be updated.
For
adding or updating a single field, The API is ‘/expandovalue/add-value'.
For
adding or updating multiple fields the API is ‘/expandovalue/add-values'.
For
getting the data (single or multiple) the API is '/expandovalue/get-data'
Below
are the sample examples - Language is the custom field added.
For
Add
Liferay.Service(
'/expandovalue/add-value',
{
companyId: 101233,
className: 'com.liferay.portal.model.User',
tableName: 'CUSTOM_FIELDS',
columnName: 'Language',
classPK: 10234,
data: 'English'
},
function(obj) {
console.log(obj);
}
);
For adding
multiple Values (Here Language and Notification Preferences are custom Fields)
Provide
the input to attributeValues as Collection object.
Liferay.Service(
'/expandovalue/add-values',
{
companyId: 101233,
className: 'com.liferay.portal.model.User',
tableName: 'CUSTOM_FIELDS',
classPK: 10234,
attributeValues: {Language:English, Notification Preference:Email}
},
function(obj) {
console.log(obj);
}
);
For
getting the data (In column Names give the multiple values for getting more
than one column data)
Liferay.Service(
'/expandovalue/get-data',
{
companyId: 101233,
className: 'com.liferay.portal.model.User',
tableName: 'CUSTOM_FIELDS',
columnNames: Language, Notification Preference,
classPK: 10234
},
function(obj) {
console.log(obj);
}
);
No comments:
Post a Comment