Posted on 26/05/2017 15:25:32
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