November Happy Hour will be moved to Thursday December 5th.

Setting ChangedBy by code is overwritten by logged in users username?

Vote:
 

Hi!

On purchase we are unpublishing products if there are no items left in stock using this code:

var productClone = product.CreateWritableClone<Product>();
productClone.ChangedBy = "ProductEOL";
productClone.StopPublish = DateTime.Now;
_contentRepository.Service.Save(productClone, SaveAction.Publish, AccessLevel.NoAccess);

The product is unpublished but the ChangedBy is set to the username of the person that purchased the last item, why is that?

We have some other functions like importing that sets ChangedBy and that works just fine. In the sync function there are no logged in user so I guess i might have something to do with that?

/Kristoffer

#268111
Dec 09, 2021 12:48
Vote:
 

Very strange. I just checked the code and ChangedBy is only set to the current user if it is null. I don't have a good answer for you however, so you should contact developer support service - there might be something else in your code that changed that 

#268482
Dec 16, 2021 9:39
Vote:
 

Thanks, I will try this in Foundation and contact the devloper support if it is the same there.

#268509
Edited, Dec 16, 2021 21:08
Vote:
 

I got curious and did a test:

If I try to set ChangedBy to "MJ" on a product I get the following results:

As anonymous: ChangedBy = "installer"
As logged in user: ChangedBy = logged in username

If I do the same on a CMS page I get

As anonymous: ChangedBy = "MJ"
As logged in user: ChangedBy = logged in username

#268741
Dec 21, 2021 7:22
Vote:
 

I alse see alot of changed by "installer" in our Commerce instance, don't know where that is coming from.

So this really is something to report. I will send this to Optimizely and have them sort things out.

Thanks Mari for your test.

/Kristoffer

#268745
Dec 21, 2021 8:29
Vote:
 

I believe installer is a system convention for "empty" ChangedBy property. 

#268747
Dec 21, 2021 11:50
Vote:
 

It is reported as COM-14467 if you want to follow up.

#268749
Dec 21, 2021 11:52
Vote:
 

Now it is a public bug and can be followed here:

https://world.optimizely.com/support/bug-list/bug/COM-14816

#270454
Jan 24, 2022 9:23
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.