4

HTML

<template>
<lightning-record-edit-form object-api-name="Contact" onsuccess={handleSuccess}>
    <lightning-messages></lightning-messages>
    <div class="slds-m-around_medium">
        <lightning-input-field field-name='Id' value={contactId}></lightning-input-field>
        <lightning-input-field field-name='LastName'></lightning-input-field>
        <lightning-input-field field-name='FirstName'></lightning-input-field>
        <lightning-input-field field-name='Email'></lightning-input-field>
        <lightning-input-field field-name='AccountId'></lightning-input-field>

        <div class="slds-m-top_medium">
            <lightning-button variant="brand" type="submit" name="save" label="Create Contact">
            </lightning-button>
        </div>
    </div>
</lightning-record-edit-form>

JS

import {
LightningElement,
api,track
} from 'lwc';

export default class app extends LightningElement {
@track contactId;
handleSuccess(event) {
    this.contactId = event.detail.id;
}

}

Am getting following error when i ran the above code in Salesforce Play Ground. Since am new to salesforce, Can some one help me on this. Thank you

enter image description here

6

Playground does not support components like lightning-record-edit-form or any other base components that requires a Salesforce connection.

You will need to use an IDE like vscode extension for Salesforce and Salesforce CLI to connect your local machine to actual Salesforce org to verify and play with components that require Salesforce UI API or Salesforce metadata API or Salesforce data.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.