Showing posts with label Salesforce object. Show all posts
Showing posts with label Salesforce object. Show all posts

Thursday, April 10, 2014

What is an sObject in Apex?

What is an sObject in Apex?


An sObject is any object that can be stored in the Force.com platform database. These are not objects in the sense of instances of Apex classes; rather, they are representations of data that has or will be persisted

sObject is a generic abstract type that corresponds to any persisted object type. The generic sObject can be cast into a specific sObject type, such as an account or the Invoice_Statement__c custom object.

This creates an invoice statement, which corresponds to the Invoice_Statement__c custom object, without setting any fields and assigns the new invoice statement to an sObject.

sObject s = new Invoice_Statement__c();


What is an object?

What is an object?


An object is an instance of a class.

All objects have state and behavior, that is, things that an object knows about itself, and things that an object can do. The state of a PurchaseOrder object—what it knows—includes the user who sent it, the date and time it was created, and whether it was flagged as important. The behavior of a PurchaseOrder object—what it can do—includes checking inventory, shipping a product, or notifying a customer.

ex:-

Order__c orderObj = new Order__c();


here “orderObj  “ is the object of the Order__c.


Saturday, February 1, 2014

Query Chatter feed item & how the structure in Salesforce object

Salesforce admin can enable Chatter feed tracking on Salesforce object, include custom objects.
Go to Setup - App Setup - Customize - Chatter - Feed Tracking
Select object to track and tick "Enable Feed Tracking", you can select up to 20 fields.

In the background, once an object is enable for feed tracking, Salesforce will create new object end with suffix Feed (for Standard object) or _Feed (for Custom object). This is available in API version 18.0 and later.

Using SOQL, you can do this query:
Select Id, ParentId, Type, Title, Body, CommentCount, LikeCount, LinkUrl, RelatedRecordId, ContentFileName, ContentSize, ContentType From Object1__Feed
This query will return all feeds tag to Object1__c object only (see ParentId field)

Another object storing all feeds is FeedItem, this object avaiable in API version 21.0 and later.
Select Id, ParentId, Type, Title, Body, CommentCount, LikeCount, LinkUrl, RelatedRecordId, ContentFileName, ContentSize, ContentType From FeedItem Order By ParentId
This query will return all feeds tag to any objects.

See architecture below (click image to enlarge):























Notice that objectFeed object shared the same prefix with FeedItem: 0D5


If you need the screenshot in Visio file, click here

 
| ,