无法使用LWC-SALESFORCE创建新记录

无法使用LWC-SALESFORCE创建新记录,salesforce,salesforce-lightning,Salesforce,Salesforce Lightning,我是LWC的新手,想知道为什么我的代码不起作用。我的要求是从VF页面调用此LWC。使用LWC,我必须在我的对象PRODUCT2\uuC中创建一个新记录。 我已经附上了我的LWC的javascript和html文件。当我遇到错误时,请让我知道我做错了什么: “创建记录时出错 尝试更新记录时出错。请重试。“ //tUButton.html <!-- @File Name : tUButton.html @Description : @Author

我是LWC的新手,想知道为什么我的代码不起作用。我的要求是从VF页面调用此LWC。使用LWC,我必须在我的对象PRODUCT2\uuC中创建一个新记录。 我已经附上了我的LWC的javascript和html文件。当我遇到错误时,请让我知道我做错了什么: “创建记录时出错 尝试更新记录时出错。请重试。“

//tUButton.html

<!--
  @File Name          : tUButton.html
  @Description        : 
  @Author             : ChangeMeIn@UserSettingsUnder.SFDoc
  @Group              : 
  @Last Modified By   : ChangeMeIn@UserSettingsUnder.SFDoc
  @Last Modified On   : 12/10/2019, 12:49:09 PM
  @Modification Log   : 
  Ver       Date            Author              Modification
  1.0    12/9/2019   ChangeMeIn@UserSettingsUnder.SFDoc     Initial Version
-->
<template>
  <lightning-card title="Add Number of Layers And Palletes" icon-name="standard:record">
    <div class="slds-m-around_medium">
        <lightning-input label="Id" disabled value={Product2}></lightning-input>
        <lightning-input label="TU per Layer" onchange={handleChangeLayer} class="slds-m-bottom_x-small"></lightning-input>
        <lightning-input label="Layer per Pallete" onchange={handleChangePallete} class="slds-m-bottom_x-small"></lightning-input>

        <lightning-button label="Submit" variant="brand" onclick={submitProduct}></lightning-button>
    </div>
 </lightning-card>
</template>
如果有人能够帮助确定问题,请提前感谢

//
 import { LightningElement, track, api } from 'lwc';
    import { createRecord } from 'lightning/uiRecordApi';
    import { ShowToastEvent } from 'lightning/platformShowToastEvent';
    import Product2_OBJECT from '@salesforce/schema/Product2';
    import NAME_FIELD from '@salesforce/schema/Product2.Name';
    //import SKULayers_FIELD from '@salesforce/schema/Product2.SKU_External_Id__c'

    export default class LdsCreateRecord extends LightningElement {
      //  @track productId;
         @track name = '';
         @api recordId;


         handleChangeLayer(event) {
            this.productId = undefined;
            this.name = event.target.value;


        }
        handleChangePallete(event) {
            this.productId = undefined;
            this.name = event.target.value;

        }
        submitProduct() {
            const fields = {};
            fields[NAME_FIELD.fieldApiName] = this.name;
            const recordInput = { apiName: Product2_OBJECT.objectApiName, fields };

            createRecord(recordInput)
                .then(product => {
                 this.productId = product.id;
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Product created',
                            variant: 'success',
                        }),
                    );
                })
                .catch(error => {
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Error creating record',
                            message: error.body.message,
                            variant: 'error',
                        }),
                    );
                });
        }
    }