cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How can I update validation on type level without saving the product in Backoffice (PCM)?

Former Member
0 Likes
432

For our customer we are migrating from cockpit to Backoffice. In the cockpit framework there are several validations on type level. It appeared that these validations don’t show/update correctly in Backoffice after fields are modified.

After some research I found out that after a value is modified only attribute validations are triggered. Type validations are not triggered.

Is it possible to show the type validations as well after values are modified without saving the product?

Case: The fields “Delivery method” and “Delivery location” are dependent on each other. When the value of “Deliver method” is equal to “Parcel” the field “Delivery location” must have a value.

Step 1: The validation message is shown correctly after the editor window is opened. Step 2: It also disappears when a value is set Step 3: But as soon as the value is removed (without saving) the validation message does not show

The validation message is shown again after the product is saved or refreshed.

Validator:

 public class DeliveryLocationValidator implements ConstraintValidator<DeliveryLocationCheck, ProductModel>
 {
     @Override
     public void initialize(final DeliveryLocationCheck annotation)
     {
         // YTODO Auto-generated method stub
     }
 
     @Override
     public boolean isValid(final ProductModel productModel, final ConstraintValidatorContext ctx)
     {
         boolean isValid = true;
 
         if(DeliveryMethod.PARCEL.equals(productModel.getDeliveryMethod())
                 && productModel.getDeliveryLocation() == null){
             ctx.disableDefaultConstraintViolation();
             ctx.buildConstraintViolationWithTemplate("Required if delivery method is set to parcel")
                     .addNode(ProductModel.DELIVERYLOCATION).addConstraintViolation();
             isValid = false;
         }
 
         return isValid;
     }
 }

Impex:

 insert_update DeliveryLocationCheckConstraint;id[unique=true,allownull=true];severity(code,itemtype(code));type(code);target;message[lang=en];annotation;active;;;;;;
         ;ProductDeliveryLocationCheckConstraint;INFO:Severity;Product;de.hybris.platform.core.model.product;not valid;net.myproject.core.validation.DeliveryLocationCheck;TRUE;;;;;;

Accepted Solutions (0)

Answers (0)