Developer forum

Forum » Development » The RMA notification email is not firing

The RMA notification email is not firing

Arker Soe
Arker Soe
Reply

Hi, I am setting up RMA for my website. I set up email for state email notifications in configuration setting for RMA in management center. let's say the default state is state A. when RMA is created, it's state will be stateA. but the email set up for stateA is not firing. but when the state is change via dw backend in ecommerce>RMA the email fired. So I am trying to trigger the state change in Notification subscriber event-RMA created event-. the thing is that I cannot change the staate of Dynamicweb.Notifications.eCommerce.Rma.CreatedArgs.Rma.State because it is readonly.  Can anyone help me with that?

Regards

Arker Soe

 


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

HI Arker,
The probelm you have maybe related to if you have just one state and it is default then in the saving this kind of RMA the StateChanged event is not triggering as the RMA state is assigned to default state when new RMA is created.
Here is a code for the RMA created event which is getting the default state and its email configuration and sends the emails:

using Dynamicweb;
using Dynamicweb.eCommerce.Orders.ReturnMerchandiseAuthorization;
using Dynamicweb.Extensibility;

namespace Dynamicweb.Examples.CSharp
{
    [Subscribe(Dynamicweb.Notifications.eCommerce.Rma.Created)]
    public class EcomRmaReplacementOrderCreatedObserver1 : NotificationSubscriber
    {
        public override void OnNotify(string notification, NotificationArgs args)
        {
            Dynamicweb.Notifications.eCommerce.Rma.CreatedArgs replacementOrderCreatedArgs = args as Dynamicweb.Notifications.eCommerce.Rma.CreatedArgs;
            if (replacementOrderCreatedArgs != null)
            {
                //get default state
                var defaultState = ReturnMerchandiseAuthorizationState.GetDefaultStateForNewRmaOrderLines();
                //get email settings for default state
                var emailConfigurations = ReturnMerchandiseAuthorizationEmailConfigurationCollection.GetEmailConfigurationByState(defaultState, "your language id");
                foreach(var emailConfiguration in emailConfigurations)
                {
                    //send emails
                    emailConfiguration.SendMail(replacementOrderCreatedArgs.Rma);
                }                
            }
        }
    }
}

Hope this will help,
Regards, Dmitrij

 

Votes for this answer: 1
 
Arker Soe
Arker Soe
Reply

Thank you for answering me Dmitriy Benyuk.  I have  7 states for notifications. i just doesn't trigger email when user created RMA. But the code works. Thank you again.

Regards, Arker Soe

 

You must be logged in to post in the forum