I have lwc. In there i get some of the fields from UI and some from apex and display it. But when I get the fields value and assign it to value fields in common fields array it's not display the values there. common fields debug does not have a value. Does someone know the reason? Please find the sample code below.
@api recordId;
objValue;
name;
phone;
primaryAddress;
tierOne;
tierTwo;
ecidValue;
ecidValue;
addressLineOne;
addressLineTwo;
addressLineThree;
countryCode;
city;
postalCode;
province;
country;
telephoneExte;
email;
fax;
@track objMetadataValues = {};
@track mapCustGroup = [];
@api targetSystemval;
result;
error;
@track initCustomerRequest = { isModelOpen: false, targetSystem: '' ,uiFields:''};
uiFields;
@wire(getRecord, { recordId: '$recordId', fields: '$fields' })
wiredRecord({ error, data }) {
if (data) {
console.log("data", JSON.stringify(data));
this.objValue = data;
if(data.apiName == 'Account'){
this.name = this.objValue.fields.Name.value;
this.phone = this.objValue.fields.Phone.value;
this.primaryAddress = this.objValue.fields.Primary_Address_1__c.value;
this.tierOne = this.objValue.fields.Tier_1_Classification__c.value;
this.tierTwo = this.objValue.fields.Tier_2_Classification__c.value;
this.ecidValue = this.objValue.fields.ECID__c.value;
this.addressLineOne = this.objValue.fields.Primary_Address_1__c.value;
this.addressLineTwo = this.objValue.fields.Primary_Address_2__c.value;
this.addressLineThree = this.objValue.fields.Primary_Address_3__c.value;
this.email = this.objValue.fields.Email__c.value;
this.countryCode = this.objValue.fields.Primary_Country_Code__c.value;
this.city = this.objValue.fields.Primary_City__c.value;
this.postalCode = this.objValue.fields.Primary_Zip_Postal_Code__c.value;
this.province = this.objValue.fields.Primary_State_Province__c.value;
this.country = this.objValue.fields.Primary_Country__c.value;
this.telephoneExte = this.objValue.fields.Phone_Extension__c.value;
this.fax = this.objValue.fields.Fax.value;
}else{
this.name = this.objValue.fields.Name.value;
this.phone = this.objValue.fields.Phone.value;
this.primaryAddress = this.objValue.fields.Primary_Address_1__c.value;
this.ecidValue = this.objValue.fields.ECID__c.value;
this.addressLineOne = this.objValue.fields.Primary_Address_1__c.value;
this.addressLineTwo = this.objValue.fields.Primary_Address_2__c.value;
this.addressLineThree = this.objValue.fields.Primary_Address_3__c.value;
}
}else{
this.error= error;
}
}
commonFields = [
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'Target System' , value: this.targetSystemval},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'ECID' , value: this.ecidValue},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'Email' , value: this.email},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'AddressLine 1' , value: this.addressLineOne },
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'AddressLine 2' , value: this.addressLineTwo},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'AddressLine 3' , value: this.addressLineThree},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'City' , value: this.city},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'Zip/Postal Code' , value: this.postalCode},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'State/Province Code' , value: this.province},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'Country Code' , value: this.countryCode},
{ input: false, text: true, combobox: false, required: false, errorMessage: '', disabled: false, label:'Fax' , value: this.fax}
];
handleCustomerRequest(event){
console.log('this.ecidValue ' +this.ecidValue + 'this.email: ' +this.email);
this.targetSystemval = event.detail.core;
this.uiFields = JSON.parse(JSON.stringify(this.commonFields));
this.displayCustomerRequest = true;
console.log('event.detail.core: ' +event.detail.core);
console.log('this.targetSystemval ' +this.targetSystemval);
console.log('JSON.parse(JSON.stringify(this.commonFields)): ' +JSON.parse(JSON.stringify(this.commonFields)));
console.log('common fields' +JSON.stringify(this.commonFields));
}