You need to sign in to do that
Don't have an account?
Girish Reddy 52
I have created a lwc form using form form tag, here I want to assign a default user to user lookup field, How can I do it?
I want to assign a default user as logged-in user to the user lookup field on my LWC form. How can I do this? Can anyone please help me with this
You Can Use Below Code to Get Current logged In User For User Field On Form Example Please Mark It As Best Asnwer If It Helps
Thank You!
I tried the code but I am using <lightning-record-form> & below is my code, I'm calling from Apex
<template>
<lightning-card>
<lightning-record-form
object-api-name={objectApiName}
fields={fields}
onsuccess={handleSuccess}>
<!-- below field I want to assign the default user -->
<lightning-output-field field-name="BMCServiceDesk__FKInitiator__c" value={user}></lightning-output-field>
</lightning-record-form>
</lightning-card>
</template>
Here I want to assign BMCServiceDesk__FKInitiator__c as logged in user by default
Please follow below url for your solution:
https://jayakrishnasfdc.wordpress.com/2020/12/08/lightning-record-form-using-lwc/
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
lightning-record-form does not support prepopulating of field values when the form loads. To create a form that displays custom field values, use the lightning-record-edit-form component.
Please Close Your Query By Marking It As Best Answer If it Helps
Thank You!