function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MOHAMMED BABAMOHAMMED BABA 

Hi Everyone, I have custom LWC user creation component , but could not able to get alias , nickname and user name autop populated could you pls help with suggestion code?

SubratSubrat (Salesforce Developers) 
Hello Mohammed ,

To autopopulate the Alias, Nickname, and Username fields in your custom LWC user creation component, you can use the lightning-input component and bind the values to variables in your JavaScript file. Here's an example of how you can achieve this:

HTML:
<template>
    <lightning-input label="Alias" value={alias} onchange={handleAliasChange}></lightning-input>
    <lightning-input label="Nickname" value={nickname} onchange={handleNicknameChange}></lightning-input>
    <lightning-input label="Username" value={username} onchange={handleUsernameChange}></lightning-input>
    <lightning-button label="Create User" onclick={createUser}></lightning-button>
</template>

JavaScript:
import { LightningElement, track } from 'lwc';

export default class UserCreationComponent extends LightningElement {
    @track alias = '';
    @track nickname = '';
    @track username = '';

    handleAliasChange(event) {
        this.alias = event.target.value;
    }

    handleNicknameChange(event) {
        this.nickname = event.target.value;
    }

    handleUsernameChange(event) {
        this.username = event.target.value;
    }

    createUser() {
        // Logic to create the user using the entered values
        // You can access the values using this.alias, this.nickname, this.username
    }
}
In the code above, we bind the values of the Alias, Nickname, and Username fields to the corresponding variables alias, nickname, and username using the value attribute of the lightning-input component. The onchange event is used to capture the changes in the input fields and update the variables accordingly. When the "Create User" button is clicked, you can access the values of the Alias, Nickname, and Username fields using this.alias, this.nickname, and this.username within the createUser method.

By using this approach, the values entered in the input fields will be autopopulated in the corresponding variables, and you can use those variables to perform further operations, such as creating the user.

If this helps , please mark this as Best Answer.
Thank you.