0

I have created LWC where i need to display task field 'ASSIGNED TO' in text format. but I am getting error as "Unsupported reference Task.Owner.Name of type sobjectField in file partnerTaskRecordReadForm.js"

.html :

<template>
<lightning-card>
    <!-- Opportunity -->
      <!-- Display -->
        <template if:true={TaskRecord}>
            <lightning-record-form 
            record-id={TaskRecord}
            object-api-name={taskObject}
            >
            <!-- Messages -->
            <lightning-messages></lightning-messages>
            <div class="slds-p-bottom_large slds-p-left_large">
            <br/>
            <!-- Fields -->
                <lightning-accordion active-section-name="A">
                    <lightning-accordion-section name="A" label="Task Details">
                        <div class="slds-grid" style="color:rgb(15, 15, 15); font-size:13px">
                            <div class="slds-col slds-size_1-of-2">
                                <div class="formfield slds-list_horizontal slds-border_bottom">
                                    <label>Assigned To</label>
                                    <div class="a11">{ownerName}</div>
                                </div>
                            </div>

                        </div>
                    </lightning-accordion-section>
                </lightning-accordion>
            </div>
            <br/>
        </lightning-record-form>
        </template>

</lightning-card>

.js file:

import { LightningElement, api, wire} from 'lwc';
import { getRecord, getFieldValue }   from 'lightning/uiRecordApi';
import Task_OBJECT                    from '@salesforce/schema/Task';
import Task_Assigned_To               from '@salesforce/schema/Task.Owner.Name';


const fields =  [Task_Assigned_To];

export default class partnerTaskRecordReadForm extends LightningElement
{
   @api  TaskRecord;
   @api  recordId;
    taskObject        = Task_OBJECT;

  @wire(getRecord, { recordId: '$TaskRecord', fields})
  Task;

  get ownerName()
  { 
      return getFieldValue(this.Task.data, Task_Assigned_To);
  }
}

It did work for opportunity, but not working for task. Can any one please suggest how to achieve this?

2 Answers 2

2

User Interface API does not support the "Task" object so you can't get the task record using the getRecord() method of lightning/uiRecordApi module.

You can find all the supported standard objects here - https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm

For your issue, you have to use the apex controller method to get the task record.

0
0

Lightning record form is not supported by Task,Event object yet as documented : https://developer.salesforce.com/docs/component-library/bundle/lightning:recordForm/documentation

You must log in to answer this question.

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