Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Gnaniyar Zubair
Creating Organization Programmatically
February 18, 2013 4:23 AM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 603

Join Date: December 19, 2007

Recent Posts

HI,

I am customizing liferay Registration flow through EXT by extending addUser Method of CreateAccountAction . While registering the user, i am creating the organization using below code:

Organization org = OrganizationLocalServiceUtil.addOrganization(userId],
OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, "some organization name", OrganizationConstants.TYPE_REGULAR_ORGANIZATION, true, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, "something", true, serviceContext);


But Always i am getting Null pointer exception for expando values as I am using some additional fields for user using expando.

I read some forum to add expando attributes into organization if you use expando values for user. So i inject those expando attributes into organization by setting in serviceContext like this?

serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes);


1. what is the purpose of injecting expando attributes while creating organization?
2. why I am getting [ExpandoBridgeImpl:507] java.lang.NullPointerException always ?
Gnaniyar Zubair
RE: Creating Organization Programmatically
February 18, 2013 6:02 AM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 603

Join Date: December 19, 2007

Recent Posts

It got resolved . Instead of passing the existing serviceContext object in CreateAccountAction, i just created new one.

Organization org = OrganizationLocalServiceUtil.addOrganization(userId],
OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID, "some organization name", OrganizationConstants.TYPE_REGULAR_ORGANIZATION, true, 0, 0, ListTypeConstants.ORGANIZATION_STATUS_DEFAULT, "something", true, new ServiceContext());



I am not sure whether i am going on right direction. But it got resolved . Not able to guess why it is throwing expando Null Pointer exception if i pass existing serviceContext object. GOK ( Google Only Knows) emoticon
Tanaji Londhe
RE: Creating Organization Programmatically
February 18, 2013 7:19 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Hi Gnaniyar,
Go thourgh this post.
http://www.liferay.com/community/forums/-/message_boards/message/17779167
Gnaniyar Zubair
RE: Creating Organization Programmatically
February 18, 2013 10:55 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 603

Join Date: December 19, 2007

Recent Posts

Thanks Tanaj. I read your forum which belongs to my query. But it is not helpful.

My question is, why do we get the Expando Null Pointer Exception while we creating the organization even after setting the expando attributues in serviceContext?
Tanaji Londhe
RE: Creating Organization Programmatically
February 27, 2013 8:42 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Hi Gnaniyar,
Did you get the solution for this issue, because same problem here.
If you have any suggestion please let me know about this issue.
Gnaniyar Zubair
RE: Creating Organization Programmatically
March 4, 2013 10:39 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 603

Join Date: December 19, 2007

Recent Posts

Yes Tanaji. It got resolved after adding new ServiceContext() instead of passing the existing one which is available in CreateAccountAction...