1

Not sure why the following code is not returning the Event's subject when exactly the same code, but replacing Event for Contact, is working without any issue. This component is executed as a Quick Action on the Event page, and due to it is not possible to use LWC on this object, the LWC is injected inside an Aura component, maybe this is the reason?

Aura component

<aura:component description="Modify Appointment"
                implements="force:hasRecordId,force:lightningQuickAction"
                controller="AppointmentService">
    
    <c:editAppointment recordId="{!v.recordId}"/>
</aura:component>

LWC html

<template>
        <template if:true={event.data}>
                <div class="slds-var-m-around_medium">
                        <p>{subject}</p>
                </div>
        </template>
</template>

LWC js

import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';

const FIELDS = [
    'Event.Subject'
];

export default class EditAppointment extends LightningElement {

    @api recordId;

    @wire(getRecord, { recordId: '$recordId', fields: FIELDS })
    event;

    get subject() {
        return this.event.data.fields.Subject.value;
    }

}

1 Answer 1

1

The UI API doesn't support all standard objects, unfortunately. If you call /ui-api/object-info/, you'll see that Event is not a supported object. This means you'll have to write some Apex to retrieve the record. A simple version that would work in your case would look like:

@AuraEnabled(cacheable=true) public static Event getEventRecord(Id recordId, String[] fields) {
  return Database.query(
    'SELECT '+String.join(fields,',')+
    ' FROM Event WHERE Id = :recordId' + 
    ' WITH SECURITY_ENFORCED')[0];
}

It's not entirely clear why some standard objects are not supported by this API, but this is the reason why. In the future, remember that you can check the error property of wired data to see if there's any errors.

You must log in to answer this question.

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