Issue
- Creating a new user in Liferay whenever a new entry is created in the Liferay Object with a default Site, Role, and password?
Environment
- Liferay DXP 7.4
Resolution
-
-
In Liferay objects, object action defines custom business logic that you run manually or automatically for object entry events.
- Navigate to Control Panel > Objects and create an object.
-
After saving the object, go to the Fields tab and click + Add and configure the fields.
- Here we need to add the fields that are required to create a user in Liferay for example: First Name, Last Name, Date of Birth, and Email address.
- Go to the Actions tab, click + Add to create an action to create a user when new entries are added, and fill up the Basic Info with
- Now Configure Action Trigger with the below details:
- Trigger: Select On After Add.
- Condition: Leave blank (optional, for conditional logic).
- Action: Add an Object Entry on User
- Map the fields from the original object to the fields of the
User
object as shown in the image:
-
-
- Now create a new Action to assign the default Role, Password, and Site to the newly created user.
-
For the second action, we need to use a Groovy script to assign the default Role, Password, and Site to the newly created user.
- Trigger: Select On After Add.
- Condition: Leave blank (optional, for conditional logic).
- Action Type: Choose Groovy Script.
Below I'm sharing some snapshots and the Groovy script for your reference.
Additional Information