Legacy Knowledge Base
Published Jun. 30, 2025

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

Written By

Koustuv Dhani

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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