Elastic Path Commerce Development

DataPolicyService methods

DataPolicyService methods

The com.elasticpath.service.datapolicy.DataPolicyService class provides methods to create, update, and read data policies.


To add a new data policy:
  1. Add the data points to the data point collection in the DataPolicy object, by running:

    DataPolicy.getDataPoints().add(DataPoint); .

  2. Add a new datapolicy object by running:

    DataPolicyService.save(DataPolicy dataPolicy).


You can update a data policy by updating the datapolicy object using the update method.


Note: You can modify settings for a data policy in the draft state only.

After modifying other properties of the data policy, update the data policy using the DataPolicyService.update() method.