0

I have a lwc component, In order to show WorkORder details page I need a relatedField on a relatedObject wich is Location.Name. I have used two methods

  • import LOCATION_NAME_FIELD from "@salesforce/schema/WorkOrder.Location.Name"
    
  • @wire(getRecordUi, {
        recordIds: "$locationId",
        layoutTypes: "Full",
        modes: "View",
        optionalFields: [
          "Location.Id",
          "Location.Name"
        ]
      })
      locationRecordUi;
    

and I still don't get any value , my question is Location Object supported ?

2 Answers 2

1

I think you want the relation name instead of the actual field API name. Try this:

import LOCATION_NAME_FIELD from "@salesforce/schema/WorkOrder.Location.Name"
1
  • still doesn't work
    – collin
    Commented Nov 25, 2019 at 14:43
1

Based on the list of supported objects here, https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_supported_objects.htm, it would appear Location is not a supported Standard Object.

https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_supported_objects

The wire adapters and JavaScript functions in lightning/ui*Api modules are built on User Interface API. User Interface API supports all custom objects and many standard objects.

Lightning web components can access Salesforce data and metadata from all custom objects and from all the standard objects that User Interface API supports.

It would be easier to do this in apex to get the values you need, so create a controller class and add a method like the following...

@AuraEnabled(cacheable=true)
public static WorkOrder getWorkOrderDetails(Id recordId) {
  return [SELECT Id, Location.Name FROM WorkOrder WHERE Id = :recordId];
}

Then in your lwc controller, add something like this...

import getWorkOrderDetails from '@salesforce/apex/somecontrollerclass.getWorkOrderDetails';

@wire(getWorkOrderDetails, {recordId : '$locationId'})wiredDetails

Then you can reference wiredDetails.data.Location.Name to display the data.

You must log in to answer this question.

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