Skip to main content Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

This my code i used(anything i need to modify,please let me know).

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

this cause error:User-added image
12 respostas
  1. 4 de jul. de 2020, 16:16

    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

     
  2. 3 de jul. de 2020, 19:59
    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.
  3. 3 de jul. de 2020, 19:57

    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');

  4. 3 de jul. de 2020, 19:42
    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?
  5. 3 de jul. de 2020, 19:07
    @cibi, or you can change line 12 if record type exists on Loan__c object.

    this.recType=data.recordTypeId;

     
0/9000