Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Andrew Jardine
Add Address to user using API
October 29, 2013 9:13 AM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

Every now and then I come across something in Liferay that makes me question my love for it. Here is one such instance.

1User user = UserLocalServiceUtil.getUserByEmail( email );


works like a charm. Very helpful.

1user.getAddresses();  // produces and immutable list


can't understand WHY -- but there is probably an easy way to do it anyway so no matter...

1user.addAddress( address );


expect this since it follows the pattern right? no.

1AddressLocalServiceUtil.addAddress( long userId, ... );


fails silently. Address is not added.

Can someone tell me how I can programatically add an address to a user?
Andrew Jardine
RE: Add Address to user using API [SOLVED]
October 29, 2013 10:52 AM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

Turns out that it was not failing but the association (I was making) was wrong. the classname should be Contact.class.getName() and the PK should be user.getContactId() (assuming that you are adding a personal address). Sure would be nice to have some docs that highlighted that.