Posted on 01/12/2021 14:43:05
Hi Alexander
Yes, it is possible. Depending on the implementation of the live integration.
When sending out emails, Pageview.IsEmailContext is set to true. Then on the pageview there is a 'context' created by the email - userid is added to this context and can be retrieved like this:
Pageview.Context.GetValue("UserID")
In your priceprovider, you have something like this: public override PriceRaw FindPrice(PriceContext context, PriceProductSelection selection) - note that this is 9.12 version which has PriceContext. This price context has a Customer property of type user which is taken from the above email context if present.
So in your priceprovider, you have to ensure that the userid send to BC is using that property and NOT Security.UserManagement.User.GetCurrentExtranetUserId(); or similar.
In Live integration dll v2, that still uses the old findprice overload, Helpers.GetCurrentExtranetUser is doing the same thing.
So - how is your live integration getting your userid send to ERP?
You can use the user on the overload above - or this piece of code:
internal static User GetCurrentExtranetUser()
{
var user = User.GetCurrentExtranetUser();
if (user == null && !string.IsNullOrEmpty(Context.Current?.Request?["UserId"]))
{
var userId = Core.Converter.ToInt32(Security.SystemTools.Crypto.Decrypt(Context.Current.Request["UserId"]));
user = User.GetUserByID(userId);
}
return user;
}