Developer forum

Forum » Templates » Issue with UserManagement:User.UserAddress.ID returning Users ID for default user.

Issue with UserManagement:User.UserAddress.ID returning Users ID for default user.

Claus Kølbæk
Claus Kølbæk
Reply

Copied from my reply - just to make it visible :)

There is a bit of an issue here it seems.

If your user has lets say ID 5 - then when u run through the users addresses, then the address not in AccessUserAddress will when u call GetValue("UserManagement.User.UserAddress.ID") return the user ID instead of address ID - which then means if the user also have 5 alternative addresses then you have 2 values listed out where the ID will be the same.

Which will end up causing an error on different implementations like fx the rapido one, where when u want to delete an address it checks if it has the same ID as the user.

 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

The Renderer for the user management frontend has something like this:

addressesTemplate.SetTag("UserManagement:User.UserAddress.ID", user.ID);
addressesTemplate.CommitLoop();

foreach (UserAddress address in user.Addresses)
{
  ...
  addressesTemplate.SetTag("UserManagement:User.UserAddress.Address.InputName", "Address");
  addressesTemplate.SetTag("UserManagement:User.UserAddress.Address.Value", address.Address);
  ...
  
  addressesTemplate.SetTag("UserManagement:User.UserAddress.ID", address.ID);
}

For the address directly on the user (with fields like AccessUser.Addres etc.) there is no unique address ID (because the values are stored directly on the user, not in AccessUserAddress) and thus you get the user ID (which is, in some way, also the address ID). Then for the addresses collection on the user (AccessUser.Addresses), you go get the actual address ID as per the code above.

Does that help?

Imar
 

 
Claus Kølbæk
Claus Kølbæk
Reply
This post has been marked as an answer

Hey Imar

You were fast :) I needed the unique identifier for the address, which is not available directly in the tags - but as u are also suggesting I did instead just look up through the UserManagement.Addresses and got it by the ID there based on the current logged user - and could get it that way through.

Something like this:

Dynamicweb.Security.UserManagement.UserAddress.GetUserAddressById(addressId).UniqueIdentifier  --- addressId parsed to int

 

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Makes sense. Not sure why the unique ID isn't there though.

Imar

 
Claus Kølbæk
Claus Kølbæk
Reply

There is a bit of an issue here it seems.

If your user has lets say ID 5 - then when u run through the users addresses, then the address not in AccessUserAddress will when u call GetValue("UserManagement.User.UserAddress.ID") return the user ID instead of address ID - which then means if the user also have 5 alternative addresses then you have 2 values listed out where the ID will be the same (5 in this case).

Which will end up causing an error on different implementations like fx the rapido one, where when u want to delete an address it checks if it has the same ID as the user.

 

 

You must be logged in to post in the forum