다음을 통해 공유


Correction: "Updates Overwrite" property of Commerce Server Profiles Adapter

A couple of days ago, I had blogged here about an error on the Commerce Server Profiles adapter.

When trying out an update to the Profile, the Commerce Server Adapter returns back the following error message -

<?xml version="1.0"?>
<CommerceServerProfilesUpdateResponse>
<InvalidProfileUpdateMessage>

The message body received by the send adapter is not valid for the CommerceServerProfilesUpdate API call. Message ID: 529029a6-5954-4446-bdd3-a5b4c5051cbb. Detail: There has been an optimistic locking conflict. The object could not be saved. This occurs when someone else makes a change to the object after you have loaded the object but before you have saved the object. To force overwriting of the other user's change, set the overwriteOnConflict flag to true. Profile Name = 'Address'. Primary Key Value = '{f8ec6880-9a9a-4059-9e10-1bb1712687ba}'. </InvalidProfileUpdateMessage>
</CommerceServerProfilesUpdateResponse>

 

The solution that I had suggested was to set the "Updates Overwrite" property on the adapter to "true". However, on exploring the avenue further, I came to know that setting this property to "true" would actually cause the Commerce Server to update all the properties for the related profile. If it is not specified as an input, then it is marked as null. This behaviour might not be desirable in most of the cases where you would not like to pass all the information. Only information that is updatable should be updated.

The "Updates Overwrite" property allows doing that by setting it to "false". However, when this propery is set to "false", the Commerce Server Webservices checks for the update timestamp on the incoming message. If the timestamp is not available or if it's value is greater than the last updated timestamp in the database, then the adapter returns back with the above error message.

To take care of this issue, all you have to do is set the "date_last_changed" & "csadapter_date_last_changed" fields in your update request message to the Commerce Server to the current datetime. This can be done by simply using the date & time functoid in the map or by distinguishing these properties and then assigning them in expression shape as -

updateRequestMessage.UserObject.ProfileSystem.date_Last_changed = System.DateTime.Now().ToString();

updateRequestMessage.UserObject.ProfileSystem.csadapter_date_Last_changed = System.DateTime.Now().ToString();

 

This will now allow you to update the profile without sending the additional information that need not be updated.

One thing that I noticed with this is that even after doing this, If I go ahead to update the profile without specifying my existing credit cards, it then deletes all the credit card links in my profile. To overcome this I have to pass the credit card ids (GUIDs) along with my user profile update message.

Comments

  • Anonymous
    April 14, 2007
    Interesting comments.. :D

  • Anonymous
    June 21, 2011
    The comment has been removed

  • Anonymous
    June 22, 2011
    after testing,  it is still overwriting and putting in NULL  for some elements..

  • Anonymous
    December 28, 2016
    last pass CORRECTION