---
schema_version: "1"
id: a3b887605a4f15fd81b9a10424f0b01923a124c991ccb50012a6251042061ba5
title: Has SObject Name
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/aura/components/force/hasSObjectName/force-has-sobject-name.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/force-has-sobject-name.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c623433740b872d5e45fea293edcab44c1b706d217b8240cd688bc8be5523ff6
products:
  - Lightning Component Reference
---
# Has SObject Name

**`force:hasSObjectName`**

Indicates that a component has the SObject name attribute.

**For Use In**

Lightning Experience, Experience Builder Sites, Salesforce Mobile App

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

Add the `force:hasSObjectName` interface to an Aura component to enable the component to be assigned the API name of current record’s sObject type. The sObject name is useful if the component can be used with records of different sObject types, and needs to adapt to the specific type of the current record. This interface has no effect except when used within Lightning Experience, the Salesforce mobile app, and sites based on Experience Builder templates.

This interface is a marker interface. A marker interface is a signal to the component’s container to add the interface’s behavior to the component. You don’t need to implement any specific methods or attributes in your component, you simply add the interface name to the component’s `implements` attribute.

This interface adds an attribute named `sObjectName` to your component. This attribute is of type String, and its value is the API name of an object, such as `Account` or `myNamespace__myObject__c`. For example:

```xml
<aura:attribute name="sObjectName" type="String" />
```

**note:** If your component implements `force:hasSObjectName`, you don’t need to add an `sObjectName` attribute to the component yourself. If you do add it, don’t change the access level or type of the attribute or the component will cause a runtime error.

**Important:** The `sObjectName` attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, `sObjectName` isn’t set, and your component shouldn’t depend on it. These unsupported contexts include a few contexts that might seem like they should have access to the current record. Examples of these other contexts include the following:

- Invoking the component from a global action (even when you’re on a record page)
- Invoking the component from header or footer navigation in an Experience Builder site (even if the page shows a record)

`force:hasRecordId` and `force:hasSObjectName` are unsupported in these contexts. While the marker interfaces still add the relevant attribute to the component, accessing either attribute generally returns `null` or `undefined`.

## Example

This example shows the markup required to add the `force:hasSObjectName` interface to an Aura component.

```xml
<aura:component implements="force:lightningQuickAction,force:hasSObjectName">

    <!-- ... -->

</aura:component>
```

The component’s controller can access the ID of the current record from the `recordId` attribute, using `component.get("v.sObjectName")`. The `recordId` attribute is automatically added to the component by the `force:hasSObjectName` interface.

For more information, see the [Lightning Aura Components Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_config_for_app_builder_intro.htm).


:::::

:::::tab
## Attributes

| Name          | Description                                                                                                                                    | Type   | Default | Required |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ------ | ------- | -------- |
| `sObjectName` | The API name of the custom or standard object, such as "Account", "Case", "Contact", "Lead", "Opportunity", or "namespace\_\_objectName\_\_c". | string |         |          |

:::::

::::::
