Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
User created programmatically doesn't show in Control panel
Hi Everyone!
I'm using Liferay CE 7.4.3-112 version and I'm trying to create a custom job, that adds users to Liferay. My problem is, that after adding user with
UserLocalServiceUtil.addUserWithWorkflow() or addUser()
the user gets created in the database, but it is not showing in the Control Panel->Users and Organizations panel, not even after reindexing everything. The created user in the database seems exactly the same as users before, that are showing just fine.
Here is my code for adding the user:
String randomPassword = UUID.randomUUID().toString(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(20098); serviceContext.setUserId(_configuration.userId()); serviceContext.setAddGuestPermissions(true); serviceContext.setIndexingEnabled(true); User user; try{ user = UserLocalServiceUtil.addUserWithWorkflow( _configuration.userId(), // e.g., default company admin userId 20098, false, // autoPassword = false randomPassword, randomPassword, false, // autoScreenName = false "john.doe", //screenName "john.doe@example.com", //emailAddress LocaleUtil.getDefault(), "John", // first name "", // middle name "Doe", // last name 0, 0, true, // prefix/suffix/male 1, 26, 2002, // birthday, month, day, year "Developer", // job title AzureLiferayUserSyncPortletKeys.AZUREUSERTYPE, null, // List of group IDs null, // List of organization IDs null, // List of role IDs null, // List of user group IDs false, // sendEmail serviceContext // ServiceContext ); } catch (Exception e) { throw new RuntimeException(e); }
I don't really understand the what the ServiceContext do in this scenario, the things I set are mainly from other forum posts in a similar context. I'm new to Liferay development, please help.
Hi Illés Ákos,
Service context you can create and add there.
Could you please match created user data with existing user in DB like
group id , company id etc.
Also, Please enable the log to get if
there is any exception.
Thanks!
Powered by Liferay™