Developer forum

Forum » Dynamicweb 10 » Issues with Swift System Emails

Issues with Swift System Emails

Kenneth Holm
Reply

Replies

 
Kenneth Holm
Reply

Hi DW,

 

When using the Email Orderlines, the template fails in the following situations:

* During preview with VisualEditor

* When finishing an order in checkout with Notifications Emails, and using Shipping Email or Custom Field Email - (It works with Billing Email or with Template instead of Page reference.)

 

Reason that it fails:

Dynamicweb Current Context does not include any reference to the Order, and therefore it cannot find the orderlines to generate.

Here is a snippet of what context objects that are available

 

Tested in 10.15.5

Another issue happens in 10.16, making it impossible to test - See below

 

/Kenneth

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Kenneth

We never really made that work completely and we are not going in that direction for a number of reasons.

How did you set it up? Are you using order context renderer?

And what does "Fails" mean in this context? Do you get an exception? Can I have it?

To fix the template issue:

The viewmodels are made "nullable enable" so they can no longer be created in instances that makes no sense. I can that the row templates in Swift 1 for emails has this line that seems to be wrong:

This line: https://github.com/dynamicweb/Swift/blob/v1.26.8/Swift/Files/Templates/Designs/Swift/Grid/Email/RowTemplates/1Column.cshtml#L14

Has to be 

var settings = parentPage != null ? Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(parentPage).Item : new PageInfoViewModel() { ID = 0 };

Or just

var settings = parentPage != null ? Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(parentPage).Item : null;

 
Kenneth Holm
Reply

Hi Nicolai,

 

I'll provide you some in multiple steps.

This is in 10.5.5, using the Visual Editor. I've done nothing but adding the template for Orderlines, which uses Orderlines.cshtml and Order Context Renderer:


It's the same exception occuring when creating an order in frontend, but I've setup an extra email notification and using the "Page" setting instead of template.
And here is the paragraph setup:


Since {{Ecom:Order.ID}} is available in a paragraph element, I guess I can make a work around for it though, without using the Order Context Renderer.

 

/Kenneth

 
Kenneth Holm
Reply

Hmm, maybe stall this a bit. I'm seing some inconsistent test results.

I'll get back when I've tracked down why it's not consistent, and what's going on.

/Kenneth

 
Kenneth Holm
Reply

Hi Nicolai,
 

I've done multiple test scenarios and narrowed down the issue. These are my results.

The first paragraph with an "Order Context Renderer" seems to fail with no PageId as highlighted in my last post. I expect the ViewModel might not be available and therefor the CurrentPageId is not set in the Context. It happens in the following scenarios that the case:

  • When sending to Custom Email or Shipping Email in Cart Module (When creating an Order)
  • In Visual Editor
  • When using the FlowStateEmail on an Order State Change


However in this scenario, it always works:

  • When sending to Billing Email in Cart Module (When creating an Order)

 

Basicly, this segment always returns 0 for CurrentPageId, in my red test scenarios:


It's not urgent for me, since crearing a dummy order context paragraphs fixes it.


/Kenneth

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ok - the orderlines.cshtml template has never been converted to Swift 2. So it tries to lookup all kinds of weird stuff not needed to set the layout.

Attached find a cleaned file that should run in Swift 2 - with not specific design.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

There is also an EmailOrderlines.cshtml - that seems to be ready for mails.

 
Kenneth Holm
Reply

Hi Nicolai,

 

Maybe I should have mentioned that I'm using Swift 1.28 - Regardless I do believe the issue is the same. I've tried the EmailOrderLines template as well, and I've been creating a custom one for debugging.- However I see how your clean file should work fine in Swift 2, since the design relation works different.

I believe the issue is in the templatefor the itemtype: Swift_EmailOrderLines.cshtml.

For some reason, CurrentPageId is never added to the Current Context, but it only happens with the FIRST Order Context Renderer. If I duplicate the row, the first one still fails, but the 2nd one works.

/Kenneth

 

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Hm

I am not too much into this, so sorry about the guessing.

Try changing this line:

https://github.com/dynamicweb/Swift/blob/v1.26.8/Swift/Files/Templates/Designs/Swift/eCom/Order/Orderlines.cshtml#L25C22-L25C23

Into this:

int currentPageId = Pageview.ID;

Votes for this answer: 1
 
Kenneth Holm
Reply

That works, causing a lot of other issues though so some remodelling needed for that approach.

Seems like the Current.Context is a bit wonky for Emails?

 

No worries, I'm also a little bit out of my comfort zone here. Swift is not my daily routine for sure :)

Thanks for the help. I won't take more of your time, unless you need more information for internal testing/fixing.

 

/Kenneth

 

You must be logged in to post in the forum