Ask - Test
User created programmatically doesn't show in Control panel
Illés Ákos, modified 21 Days ago.
User created programmatically doesn't show in Control panel
New Member Post: 1 Join Date: 11/4/24 Recent PostsHi 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.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™