legacy-knowledge-base
公開されました Jun. 30, 2025

Creating a New User in Liferay Whenever a Liferay Object Entry is Added with Default Site, Role, and Password

投稿者

Koustuv Dhani

knowledge-article-header-disclaimer-how-to

knowledge-article-header-disclaimer

legacy-article

learn-legacy-article-disclaimer-text

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:

2024-11-29_17-56.png

    • 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.

    • AssignRoleAction.png
    • 2024-11-20_11-01.png

Additional Information

 

 

did-this-article-resolve-your-issue

legacy-knowledge-base