Customize editing of customer

Vote:
 

Hello! 

We're using CMS & Commerce with external Single Sign-On provider (OIDC). We would like administrators to be able to modify customer data via Commerce Manager, and make these changes reflect in login provider. To achieve that, we implemented custom IPlugin that updates customer data in login provider on CustomerContact edit.
However, there might be situations when customer cannot be modified (for example, due to invalid data entered by administrator). 
Throwing exception from IPlugin reverts the change, but causes whole web request fail - so the administrator see general 500 error page, which is unwanted. Are we able to fail an action "gracefully" from that plugin, or somehow cancel it in a way that administrator would see what happened (or - at best - which field caused an error)?  


Epi 11.18.X, Commerce 13.14.X

Kind regards

#227927
Sep 16, 2020 13:11
Vote:
 

How you are throwing an exception in IPlugin?

I'm using the following code snippet and it works fine

var contact = context.Request.Target as CustomerContact;
 if (contact  == null) throw new NotSupportedException("Support create Contact only!");
#249342
Feb 28, 2021 0:14
Vote:
 

The exact code looks very similar - more or less like

var result =  // API call
if (!result.Succeeded)
{
    throw new ApplicationException("This action cannot be performed"); 
}

In terms of effect, it works - change in Commerce DB is rollbacked and previous state of the user is preserved. However, I'd like the administrator to see something less scary than error 500 page... ;) 

#249384
Mar 01, 2021 7:12
Vote:
 

You can simply return like 

if (!result.Succeeded)
{
    return; 
}

Ideally, it should be returned with the message. I'll do some experiments with my IPlugin and will let you know. 

I'm doing all form validation on the client-side.

#249394
Mar 01, 2021 12:12
Vote:
 

As I said in the above reply, you can use return if your result is not Succeeded and it would not give 500 error to the user.

To show a user-friendly message...

I assume you have already generated Typed Business Foundation classes

You need to edit ContentFrame.aspx file to show a user-friendly error. 

You can use Js to get the message from BE & show or simply put it in session and get it in aspx file (sorry by webforms knowledge is a bit rusty) 

All the above seems like workarounds. @Quan probably know more about it. 

#249408
Mar 01, 2021 15:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.