2

I am getting an error of [LWC component's @wire target property or method threw an error during value provisioning. Original error: [Invalid recordInput]] when trying to use updateRecord

Below is the code

import { LightningElement, api, wire, track } from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import QUOTE_OBJECT from '@salesforce/schema/SBQQ__Quote__c';
import SubmitQuoteForApproval from 
'@salesforce/apex/clsSubmitObjectForApproval.SubmitForApproval';
const FIELDS = ['SBQQ__Quote__c.RecordTypeId'];
import { getRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { CloseActionScreenEvent } from 'lightning/actions';
import { getRecordNotifyChange } from 'lightning/uiRecordApi';
import { updateRecord } from 'lightning/uiRecordApi';
import SALESORDER_FIELD from '@salesforce/schema/SBQQ__Quote__c.Sales_Order__c';

export default class LwcSubmitQuoteToOrder extends LightningElement {

@api recordId;
@api objectApiName;
@track quote;
@track ValidationMessage;
@track recordType;
@track objectInfo;


@wire(getObjectInfo,  { objectApiName: QUOTE_OBJECT })
ObjectInfo;

@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
wiredRecord({error, data }) {
    if(data) {
        this.quote = data;
 
        this.recordType = this.quote.fields.RecordTypeId.value;
        
        //Must declare that ValidationMessage be nothing. 
        this.ValidationMessage  = '';


       if(this.GetRecordTypeValue() == true){
            this.ValidationMessage = this.ValidationMessage +  'This is a Sales Order\n';
            
            this.UpdateQuote();
          
        }
    } 
    
    
UpdateQuote(){
    const fields = {};
    fields[SALESORDER_FIELD.fieldApiName] = true;
    
    const recordInput = { fields };
    updateRecord(recordInput);
}   

async invokeApexMethods() {
        // Update the record via Apex.
        await SubmitQuoteForApproval({idObject: this.recordId})
        // Notify LDS that you've changed the record outside its mechanisms.
        getRecordNotifyChange([{recordId: this.recordId}]);
}

closeAction(){
   this.dispatchEvent(new CloseActionScreenEvent());
}
  
showErrorToast(x) {
    const evt = new ShowToastEvent({
        title: 'Submit Quote For Approval',
        message: x,
        variant: 'Quote has Successfully Submitted',
        mode: 'dismissable'
    });
    this.dispatchEvent(evt);
} 

 GetRecordTypeValue() {
    // Returns a map of record type Ids 
    const rtis = this.ObjectInfo.data.recordTypeInfos;
    const rtInfo= Object.keys(rtis).find(rti => rtis[rti].name == 'Official_Sales_Quote');
    
    if(this.RecordType===rtInfo){
        return true;
    } else{
        return false;
    }  
    
}

}

1 Answer 1

5

Per documentation you need to provide record id.

const fields = {};
fields[ID_FIELD.fieldApiName] = this.contactId;
fields[FIRSTNAME_FIELD.fieldApiName] = this.template.querySelector("[data-field='FirstName']").value;
fields[LASTNAME_FIELD.fieldApiName] = this.template.querySelector("[data-field='LastName']").value;

const recordInput = { fields };
1
  • Thanks i must have missed that somehow
    – CodeMonger
    Aug 31, 2021 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .