function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Denise CrosbyDenise Crosby 

component attribute default sobjectType - can you use whatever name/value pairs you want?

Hello Salesforce experts,
I was going through my Salesforce Dev601 training manual from Developing Lightning Components. In the second chapter, there's this:
<aura:attribute name="student" type="Contact" access="public" 
default="{'sobjectType':'Contact','Name':'John Smith',PhotoUrl:'/services/images/photo/003B0000009VnYcIAK'}"/>
Was just wondering how that works? Name and PhotoUrl are not fields in the Contact object, so can I define this student attribute default with any name/value pairs I want even though I define it as a type of Contact? So confused...

Thanks for helping.
Best Answer chosen by Denise Crosby
Alain CabonAlain Cabon
Hi Denise,

Name is a special field (concatenation) and they exist both into the free developer orgs.

SOQL request works : select Name, PhotoUrl from contact

Name Type: string 
Description: Concatenation of FirstName, MiddleName, LastName, and Suffix. Maximum size is 121 characters.

PhotoUrl  Type: url
Description: Path to be combined with the URL of a Salesforce instance (for example, https://yourInstance.salesforce.com/) to generate a URL to request the social network profile image associated with the contact. Generated URL returns an HTTP redirect (code 302) to the social network profile image for the contact.
Blank if Social Accounts and Contacts isn't enabled for the organization or if Social Accounts and Contacts is disabled for the requesting user.

​https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm)
 

All Answers

Alain CabonAlain Cabon
Hi Denise,

Name is a special field (concatenation) and they exist both into the free developer orgs.

SOQL request works : select Name, PhotoUrl from contact

Name Type: string 
Description: Concatenation of FirstName, MiddleName, LastName, and Suffix. Maximum size is 121 characters.

PhotoUrl  Type: url
Description: Path to be combined with the URL of a Salesforce instance (for example, https://yourInstance.salesforce.com/) to generate a URL to request the social network profile image associated with the contact. Generated URL returns an HTTP redirect (code 302) to the social network profile image for the contact.
Blank if Social Accounts and Contacts isn't enabled for the organization or if Social Accounts and Contacts is disabled for the requesting user.

​https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm)
 
This was selected as the best answer
Denise CrosbyDenise Crosby
Thanks Alain. I'll have to keep the SOAP API Developer Guide bookmarked for later. And name, I can't believe I missed that. Thanks so much for helping. It's all starting to make sense.