on 2018 Aug 29 2:46 PM
Hello Experts,
I've tried to delete enum value for one of dynamic type from HMC/Impex/Code, I am getting following error,

If I create some value through hmc, I am able to delete them, but not the ones defined in items.xml file, When I try to debug I understand in DB editable column having null for EnumerationValues table, I am not sure why dynamic enums are holding null. If I change editable to true from DB directly, I am able to delete item.
Is there any proper way to delete it? Through code or HMC or Impex?
Note : I am using Hybris 5.7 version.
Thanks
Request clarification before answering.
I used this strategy to remove a custom ProductReferenceTypeEnum value from Hybris.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe this would be the full implementation...
import de.hybris.platform.core.model.enumeration.EnumerationValueModel
import de.hybris.platform.enumeration.impl.DefaultEnumerationService
import de.hybris.platform.jalo.Item
import de.hybris.platform.jalo.JaloSession
import de.hybris.platform.jalo.enumeration.EnumerationValue
import de.hybris.platform.persistence.enumeration.EnumerationValueEJBImpl
import de.hybris.platform.servicelayer.model.ModelService
import de.hybris.platform.servicelayer.type.TypeService
final ModelService modelService = spring.getBean('modelService')
final TypeService typeService = spring.getBean('typeService')
final DefaultEnumerationService enumerationService = spring.getBean('enumerationService')
final EnumerationValueModel enumerationValueModel = typeService.getEnumerationValue(enumerationService.getEnumerationValue("LeadStatus", "NEGOTIATION_REVIEW"));
final Item item = (EnumerationValue) modelService.getSource(enumerationValueModel);
((EnumerationValueEJBImpl) item.getImplementation()).remove(JaloSession.getCurrentSession().getSessionContext());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
: Can you please provide full implementation class for my reference. I need to do same thing. Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Thanks for quick response, I am able to figure out alternative solution,
final EnumerationValueModel enumerationValueModel = typeService.getEnumerationValue(enumerationService.getEnumerationValue("LeadStatus", "NEGOTIATION_REVIEW"));
final Item item = (EnumerationValue) getModelService().getSource(enumerationValueModel);
((EnumerationValueEJBImpl) item.getImplementation()).remove(JaloSession.getCurrentSession().getSessionContext());
Using jalo layer code is not an recommended approach, However it's an one time data correction activity post deployment.
Thanks, Phani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey ,
Unfortunately since 5.1.X version it seems that the editable flag for OOTB enumerations is null by default (instead of 1), so it's not possible to remove the values of OOTB enumerations.
The workaround is to create a new enum without the unwanted values and replace references to the original enum with the newly created enum.
Hope that helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.