[SalesForce] getFieldValue not working properly in LWC

I am trying to retrieve the field value once a record is created and submit button is pressed. So I am getting the record Id via event.detail.id in my js but I tried retrieving the value with the Id but it is not working. In the result value, I am always getting the record id instead of the field value of the record. Can anyone highlight where I am going wrong? Here is my javascript and html. Thanks in advance!

Javascript:

import { LightningElement, api, track, wire } from "lwc";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { NavigationMixin } from "lightning/navigation";
import {getRecord, getFieldValue} from 'lightning/uiRecordApi';
import NAME_FIELD from '@salesforce/schema/Invoice__c.Name';

export default class ContactRecord extends NavigationMixin(LightningElement) {
  @api recordId;


  @wire(getRecord, { recordId: 'a052v00000pulwaAAA', NAME_FIELD })
    invoice;

// eslint-disable-next-line no-unused-vars
  handleSubmit(event) {
    window.console.log("I am here");
    this.dispatchEvent(
      new ShowToastEvent({
        title: "Sucess!",
        message: "Successfully saved",
        variant: "success"
      })
    );
  }

    get name(){
    window.console.log(this.invoice.data);
    return getFieldValue(this.invoice.data, NAME_FIELD);
  }

  handleReset(event) {
    const inputFields = this.template.querySelectorAll("lightning-input-field");
    window.console.log("InputFields" + inputFields);
    if (inputFields) {
      inputFields.forEach(field => {
        field.reset();
      });
    }
  }

}

HTML

 <template>
  <div class="slds-p-bottom_large slds-p-left_large">
    <div class="hello">
      <lightning-record-edit-form
        object-api-name="Invoice__c"
        id="createInvoiceForm"
        onsubmit={handleSubmit}

      >
        <lightning-messages></lightning-messages>
        <lightning-input-field field-name="Name"></lightning-input-field>
        <lightning-input-field
          field-name="Total_Amount__c"
          required
        ></lightning-input-field>
        <lightning-input-field field-name="Password__c"></lightning-input-field>
        <lightning-button
          class="slds-p-right_x-small"
          type="submit"
          label="Submit"
        ></lightning-button>
        <lightning-button
          class="slds-m-top_small"
          label="Reset"
          onclick={handleReset}
        ></lightning-button>
      </lightning-record-edit-form>
    </div>
  </div>

  <lightning-record-view-form object-api-name="Invoice__c" record-id={recordId}>
    <div>
      <lightning-output-field field-name="Name"> </lightning-output-field>
      <lightning-output-field
        field-name="Total_Amount__c"
      ></lightning-output-field>
      <lightning-output-field field-name="Password__c"></lightning-output-field>
    </div>
  </lightning-record-view-form>

  <template if:true={invoice.data}>
    <div>
      <lightning-layout-item padding="around-small">
        <p>Name : {name}</p>
      </lightning-layout-item>
    </div>
  </template>



</template>

Best Answer

In this line:

const result = getFieldValue(record, PASSWORD_FIELD);

If you want to make getFieldValue function work - you have to pass record object instead of record Id:

Wire Adapter Parameters:

record—(Required) A Record object from which to retrieve the field value.

field—(Required) The API name of the field.

See here: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.reference_get_field_value