This my code i used(anything i need to modify,please let me know).
this cause error:import { LightningElement, track, api,wire } from 'lwc';
import { getRecord,getFieldValue } from 'lightning/uiRecordApi';
@track recType;
@api recordId;
@track LjobsValue;
@track CjobsValue;
@track MjobsValue;
@wire(getRecord, { recordId: '$recordId', layoutTypes: ['Full'], modes: ['View'] })
wiredRecord({data,error}) {
if (data) {
var result = JSON.parse(JSON.stringify(data));
this.recType=result.recordTypeId;
this.LjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Lost__c');
this.MjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Maintained__c');
this.CjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Created__c');
}
else{
this.error=error;
console.log(error);
}
}
i used this code it throws error in console
Then the lookup relationship field (Account__r) is not valid. You have to find out what is the field name in loan__c object setting.
You can try the following soql in developer console, and I think it will tell you such field not exist.
select id,account__r.name from loan__c
It dosen't worked getFieldValue(data,'Loan__c.Account__r.Name'); @David If you have a lookup to Account, you can use getFieldValue(data,'Loan__c.Account__r.Name'); to get accout name. same pattern for other fields in parent object. Can we use like this to. Access look up relationship field's loan with Account object :- it this possible? @David
this.MjobsValue=getFieldValue(data,'Loan__c.Account__r.Total_Jobs_Maintained__c'); this.CjobsValue=getFieldValue(data,'Loan__c.Account__r.Total_Jobs_Created__c');
Thanks @David ,one more doubt i have look up relationship loan with account object in that account object i have same fields there in loan.how to access i dont know ,u have idea? @cibi, or you can change line 12 if record type exists on Loan__c object.this.recType=data.recordTypeId; Hi Cibi, I found an article that was very similar to yours. I believe it’ll solve the issue you are having: https://developer.salesforce.com/forums/?id=9062I000000QwLGQA0 @David so i need to remove the line 12 ? And yes that are all fields of loan__c object @christan yes i tried by removing the JSON file but same don't work it throws error same