1

Below is a portion of my LWC js controller. I'm trying to write a function to see if a field in a parent record of an Event record has a certain value. I'm baffled by what is returned by getFieldValue(). It returns the entire Event record. That is demonstrated by the following console.log() statement. The line after that actually gets the field value and my function works correctly. I do not understand why the getFieldValue didn't give me the actual value and I needed the line that sets customFieldValue. Any ideas?

import { getFieldValue } from 'lightning/uiRecordApi'; import getEvent from '@salesforce/apex/MyCustomController.getEvent'; import CUSTOM_FIELD from '@salesforce/schema/Event.MyCustomObject__r.MyCustomField__c'; @wire(getEvent, { eventId: '$recordId' }) sfEvent; get isNotSomeValue() { const customField = getFieldValue (this.sfEvent.data, CUSTOM_FIELD); console.log(JSON.stringify(customField)); const customFieldValue = meetingStatus.MyCustomObject__r.MyCustomField__c; console.log("customFieldValue => " + customField); return ( customFieldValue != 'SomeValue'); } 

1 Answer 1

1

I firgured it out. With the record coming from Apex, I need to use getSObjectValue() instead of getFieldValue ()

import { getSObjectValue } from '@salesforce/apex'; ... const customFieldValue = getSObjectValue (this.sfEvent.data, CUSTOM_FIELD); 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.