You need to sign in to do that
Don't have an account?
Moon Knight
Insert record in Contact Object using LWC
Need urgent help for this Question related to LWC.--
Make two address fields on CONTACT Object , correspondence address and permanent address.
We have to fill both the fields with different addresses, if anyone of them is empty then generate message,
and if the checkbox is selected then both the addresses should be same. I Have to do this with LWC
// i have created 2 custom field on contact and 1 checkbox field as well.
..only below field requried in LWC page according to my question's requirement-- .
Last Name =
Email =
correspondence address =
checkbox = [true,false]
permanent address =
// can anyone help me , I will be really greatful :-)
// make this simple and easy as much you can,but i need this urgently,plese
Make two address fields on CONTACT Object , correspondence address and permanent address.
We have to fill both the fields with different addresses, if anyone of them is empty then generate message,
and if the checkbox is selected then both the addresses should be same. I Have to do this with LWC
// i have created 2 custom field on contact and 1 checkbox field as well.
..only below field requried in LWC page according to my question's requirement-- .
Last Name =
Email =
correspondence address =
checkbox = [true,false]
permanent address =
// can anyone help me , I will be really greatful :-)
// make this simple and easy as much you can,but i need this urgently,plese
Check below examples for inserting record in Contact Object using LWC
https://www.w3web.net/creating-record-in-contact-object-and-redirecting-in-lwc/
https://developer.salesforce.com/forums/?id=9062I000000XsulQAC
Please mark as Best Answer if above information was helpful.
Thanks,
i already saw that examples, that was not helpful,because in my question i have to apply validation conditions and also i have checkbox field.
can anyone write or send me full code of html and js for this question
FNAME
LNAME
Phone
EMAIL
Please refer to below code and make improvements according to yourself :
<!-- HTML Start -->
<lightning-record-edit-form
object-api-name={objectApiName}
record-id={recordId}
>
<lightning-input-field field-name={lastnameField}></lightning-input-field>
<lightning-input-field field-name={emailField}></lightning-input-field>
<lightning-input-field field-name={correspondenceAddField} value={cAdd} onchange={handleCAdd}></lightning-input-field>
<lightning-input-field field-name={checkboxField} onchange={handleCheckbox}></lightning-input-field>
<lightning-input-field field-name={permanentAddField} value={pAdd} disabled={sameAdd}></lightning-input-field>
<div class="slds-var-m-top_medium">
<lightning-button variant="brand" type="submit" label="Save">
</lightning-button>
</div>
</lightning-record-edit-form>
<!-- HTML END-->
// JS Start
import { LightningElement, api , track} from 'lwc';
export default class yourComponentName extends LightningElement {
// Flexipage provides recordId and objectApiName
@api recordId;
@track objectApiName = 'Put Your Object APi Name';
@track lastnameField = 'Put Your lastnameField API Name';
@track emailField = 'Put Your Email API Name';
@track correspondenceAddField = 'Put Your correspondenceAddField API Name';
@track checkboxField = 'Put Your checkboxField API Name';
@track permanentAddField = 'Put Your permanentAddField API Name';
@track cAdd;
@track pAdd;
@track sameAdd;
handleCAdd(event){
this.cAdd = event.target.value;
}
handleCheckbox(event){
if(event.target.value == true){
this.sameAdd = true;
this.pAdd = this.cAdd;
}
else{
this.sameAdd = false;
}
}
}
// JS End
If this helps mark this answer as the best.
Thanks & Regards
Tushar Mathur