Developer forum

Forum » Integration » Order Custom Fields - Updated from Integration

Order Custom Fields - Updated from Integration

Rui Silva
Reply

I’ve an integration that uses a custom order field to show a ERP message to the end user. The field is being correctly updated in the Dynamicweb database but in the template the tag generated does not match the value in the database. To have the custom field correctly saved in database I use the Save method of the order.

 

I’ve tried to use API to load the order from the database and the result is also the same, does not show the saved value in database.

var orders = Dynamicweb.eCommerce.Orders.Order.GetOrders(string.Format("select * from ecomorders where orderid = '{0}'", GetString("Ecom:Order.ID")));

var order = orders[0];

<p>@order.OrderFieldValues.First(x => x.OrderField.SystemName.Equals("OrderVoucherNotification")).Value</p>

 

Or even like this:

var order = Dynamicweb.eCommerce.Orders.Order.GetOrderByID(GetString("Ecom:Order.ID"));

<p>@order.OrderFieldValues.First(x => x.OrderField.SystemName.Equals("OrderVoucherNotification")).Value</p>

 

Are the order custom fields cached in somewhere and not being correctly updated when the integration changes the values?

 

Thanks,

Rui Silva


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Rui,
I need some more information before finding an answer. What Dynamicweb version are you using? And what Integration is used:
batch(what destination provider used) or live?
Regards, Dmitrij

 
Rui Silva
Reply

Hi Dmitrij,

The Dynamicweb version is 8.9.1.13 and the field is updated by live integration.

Thanks,

Rui Silva

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Rui,
can you try to call:

var order = Dynamicweb.eCommerce.Orders.Order.GetOrderByID(GetString("Ecom:Order.ID"), false);

Regards, Dmitrij

 
Rui Silva
Reply

Hi,

Just tried that and no change on the result.

Thanks,

Rui Silva

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Rui,
in what case are you using the showing of the updated order from ERP?
Is that on CartLineAdded/Removed or CheckOutDone or ExtranetLogin or CartInitiallyLoaded?
Regards, Dmitrij

 
Rui Silva
Reply

Hi Dimitirj,

The razor template the is showing the order is the ShowCart page, under the eCom7/CartV2 folder.

The Integration is updating the order based on the Notifications.eCommerce.Cart.Loaded.

This solution needs this working fine because is going live in the next few weeks.

BR,

Rui Silva

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

HI Rui,

I was not able to reproduce this issue.
The tags I used:
@{
  var order = Dynamicweb.eCommerce.Orders.Order.GetOrderByID(GetString("Ecom:Order.ID"));
}

<p>@order.OrderFieldValues.First(x => x.OrderField.SystemName.Equals("DeliveryDate")).Value</p>

I was saving the orderfield values in order.Save() just in CartLoaded event
and the order was saved and the template code which resides in ShowCartInformation template show me the value.
Could you check your template code and also check you are using correct system name and its casing ?
Is your orderfield value keeps having the saved value from the ERP in database (isn't it get erased at some time during page loading/etc)?
Can you share the link to your solution to me?
Regards, Dmitrij

 
Rui Silva
Reply

Hi Dmitrij,

Can you send me your email to: rsi@dynamicwebusa.com so I can share with you the solution link and if needed more details to login to the solution.

Thanks,

Rui Silva

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

Hi Rui,

I've found that you are trying to validate the Order Voucher code from the cart page and the validation result is going to be stored in the Order custom field value.

It looks like you are not using the last version of the LiveIntegration sources and  using some custom code.
From the logs I can not catch where the problem is. But when you click “Apply” button
3 requests are made to External system
and the first of them is with an old voucher code value, next 2 are with correct entered value.
So can you try to get latest version and use updated files:
- Connector.cs – to get more information in the logs,
- CartInitiallyLoaded.cs subscriber instead of CartLoaded – this should decrease amount of requests
and add one more subscriber
- Notifications.eCommerce.Cart.AfterDefaultPropertiesValueIsChanged – called when the value was changed(so should be called when the changed “EcomOrderVoucherCode” value is submitted)
So you could try to subscribe to it and validate your voucher in the External system and update the order after.

Regards, Dmitrij

Votes for this answer: 1
 
Rui Silva
Reply

Hi Dmitrij,

 

I've added the Notifications.eCommerce.Cart.AfterDefaultPropertiesValueIsChanged and it begin to work fine.

Thanks for all the support,

Rui Silva

 

You must be logged in to post in the forum