cancel
Showing results for 
Search instead for 
Did you mean: 

Validator messages are not properly displayed in Backoffice - SAP Commerce 1905

gguidastri
Discoverer

Hello,

We are facing an issue with the SAP Commerce 1905 related to some Validator Interceptor. The exception that is thrown by those interceptors is not being displayed properly in Backoffice notification widget. Instead of that, a generic error message "Unable to Update" or "Unable to Create" is displayed.

When I was working on another project that was using SAP Commerce 6.7, it was not happening. Do you have any ideas about what changed, or how can I display my custom interceptor messages in Backoffice again?

Thanks!

0 Kudos

I am facing same issue, any solution available for this.

Accepted Solutions (0)

Answers (2)

Answers (2)

Hello,

When a ModelSavingException occurs within the Backoffice, eventually a NotificationEvent is published via the OOTB NotificationService. The messages for each NotificationEvent can be configured from within the -backoffice-config.xml files in each backoffice extension.

The default messages for all models' creation, update, removal, etc. are part of the platformbackoffice extension, therefore part of the platformbackoffice-backoffice-config.xml.

For example, the notification for failed update of a model is defined as follows:

<na:notifications eventType="UpdateObject" level="FAILURE">
   <na:message>user.notification.items.unable_to_update</na:message>
   <!-- Expected map in form object -> exception -->
   <na:references linksEnabled="true">
      <na:reference placeholder="0"
                 label="#root.size() == 1 ? (@labelService.getObjectLabel(#root.keySet().iterator().next()) + ' | ' + @exceptionTranslationService.toString(#root.values().iterator().next())) : #root.size()"
                 message="#root.keySet().iterator().next()" link="#root.size() == 1"/>

   </na:references>
</na:notifications>

Since the definition above seems to be the same for both SAP Commerce 6.7 and SAP Commerce 19.05, my guess would be that the implementation of the ExceptionTranslationService.toString() method has been changed after version 6.7.

That being said, in order to change the message shown in the Backoffice, there are a few possible options, including but not limited to:

  • Override the OOTB ExceptionTranslationService.toString() method so that it returns the desired custom message. Needless to say, this will override all usages of the method throughout the system.
  • Redefine the notifications element for eventType="UpdateObject" level="FAILURE" in your custom backoffice extension, so that it doesn't use the ExceptionTranslationService at all.

P.S. Although this is an old question, there seem to be people who face the same issue, therefore the answer.

BR,

Kremena

0 Kudos

Hi Kremena,

Thank you for your response. I found below link in documentation. But not able to find backoffice-core-spring.xml and bean definition for defaultExceptionTranslationService in 1905. Is there any way to enable it .

https://help.sap.com/viewer/5c9ea0c629214e42b727bf08800d8dfa/1905/en-US/8bc9570b86691014a901c290d2c5...

I can see exception is shown my logs but same is not shown on notification area of backoffice. Same is working for me in 1808.

sample log

Caused by: de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator$MissingMandatoryAttributesException: [de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator@16940d83]:missing values for [brandCategoryID, brandLogo, brandName] in model configuratorModel (<unsaved>) to create a new Configurator INFO | jvm 1 | main | 2020/07/14 13:06:54.054 | at de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator.onValidate(MandatoryAttributesValidator.java:104) ~[coreserver.jar:?] INFO | jvm 1 | main | 2020/07/14 13:06:54.055 | at de.hybris.platform.servicelayer.internal.model.impl.wrapper.ModelWrapper.invokeValidateInterceptors(ModelWrapper.java:296) ~[coreserver.jar:?] INFO | jvm 1 | main | 2020/07/14 13:06:54.055 | at

Regards,

Amrita

0 Kudos

Hi Amrita,

As it is mentioned in the documentation you found, the defaultExceptionTranslationService is defined in the backoffice-core-spring.xml. You should be able to find it within the /hybris folder. If you want to extend the service and redefine the bean, you should do so in your custom extension.

BR,
Kremena