Salesforce基础学习 自我记录

object定义的时候,可以用一般sobject定义标准object或者custm object
定义方法如下

sObject sobj1 = new Account(Name='Trailhead');
sObject sobj2 = new Book__c(Name='Workbook 1');

一般sobject可以分配给具体的object,分配后,就可以使用 ".字段"的方式取值,sobject不具备 ".字段"的方式。
方法如下

// Cast a generic sObject to an Account
Account acct = (Account)myGenericSObject;
// Now, you can use the dot notation to access fields on Account
String name = acct.Name;
String phone = acct.Phone;

SOQL中不能使用select *查询,必须指定查询的字段,
SOQL查询时,不需要指定ID字段,每次的查询结果集中必定会返回ID。
除非ID是唯一的一个查询字段,为了避免select语法错误,要加上SELECT Id FROM Account

自定义controller进行
列排序代码实现

public class ContactsListController {
    private String sortOrder = 'LastName';
    
public List getContacts() {
    
    List results = Database.query(
        'SELECT Id, FirstName, LastName, Title, Email ' +
        'FROM Contact ' +
        'ORDER BY ' + sortOrder + ' ASC ' +
        'LIMIT 10'
    );
    return results;
}
    public void sortByLastName() {
    this.sortOrder = 'LastName';
}
    
public void sortByFirstName() {
    this.sortOrder = 'FirstName';
}
}

visualforce侧:


    
        
        
        
        
        
            
                
                    
                        
                        
                    
                
            
            
                
                    Last Name
                    
                
            
            
            
            
        
        
    


  • Who comprises your target audience? Are you going after large
    enterprise customers? Mid-size? Small?
  • What is your business strategy? When and how much must you sell to
    have a successful business?
  • Which Salesforce editions will you support? For example,
    Professional, Enterprise, or Unlimited.
  • Which license type do you want to use? We offer CRM, Platform, and
    Communities.
  • Is your staff familiar with the Salesforce platform? If not, get them
    up to speed using resources like Trailhead.
  • What is your strategy for ensuring that your offering is secure?

指定对象action和全局action的区别

Object-Specific Actions in the Salesforce App

To kick off our discussion of object-specific actions, let’s talk about what makes them different than global actions.

Object-specific actions can update records.
指定对象的可以修改记录

Object-specific actions can create records that are automatically associated with related information. For example, a user could initiate an action that simultaneously creates a contact and associates it with an account.
指定对象的自动创建关系
全局的只能创建不包含关系的对象记录

sosl查询可以查询的字段
文本字段 关键字只能是下面几种
ALL FIELDS,NAME FIELDS,PHONE FIELDS

Use SOQL when you know in which objects or fields the data resides and you want to:

Retrieve data from a single object or from multiple objects that are related to one another.
Count the number of records that meet specified criteria.
Sort results as part of the query.
Retrieve data from number, date, or checkbox fields.

Use SOSL when you don’t know in which object or field the data resides and you want to:

Retrieve data for a specific term that you know exists within a field. Because SOSL can tokenize multiple terms within a field and build a search index from this, SOSL searches are faster and can return more relevant results.
Retrieve multiple objects and fields efficiently, and the objects might or might not be related to one another.
Retrieve data for a particular division in an organization using the divisions feature, and you want to find it in the most efficient way possible.

soql在明确知道从哪个对象中取值,并且取得什么字段,大多数情况都是用soql
sosl不能明确在哪个对象中存在,只知道要查询的内容

系统自动设定的index,在查询的时候,如果把index作为条件,可以增加命中率,减少查询时间。
Indexed Field Description

  • Id Unique 18-character field that is system generated. This is the
    primary key for the object.
  • Name Text-based field.
  • OwnerId Reference to the owner of the object.
  • CreatedDate Date and time when the record was created.
  • SystemModStamp Read-only field that contains the last date that the
    record was updated. This field is indexed where the similar
    LastModifiedDate is not, so consider using this one in your queries.
  • RecordType Id of the RecordType. RecordTypes are used to offer
    different UI results to certain users.
  • Master-Detail Fields Foreign key field used to indicate a
    master-detail relationship
  • Lookup Fields Foreign key field used to indicate a lookup
    relationship
  • Unique Fields Custom fields can be marked as unique when they are
    created, and this will automatically make them indexed.
  • External ID Fields Like unique fields, these custom fields can be
    marked as an External Id and are mainly used for integration
    purposes.

Trigger.
For example, Trigger.New contains all the records that were inserted in insert or update triggers. Trigger.Old provides the old version of sObjects before they were updated in update triggers, or a list of deleted sObjects in delete triggers. Triggers can fire when one record is inserted, or when many records are inserted in bulk via the API or Apex. Therefore, context variables, such as Trigger.New, can contain only one record or multiple records. You can iterate over Trigger.New to get each individual sObject.

trigger events

before insert
before update
before delete
after insert
after update
after delete
after undelete

Salesforce基础学习 自我记录_第1张图片Salesforce基础学习 自我记录_第2张图片Salesforce基础学习 自我记录_第3张图片trigger一次执行SOQL最多200条记录,DML150条记录

As of the Spring ‘19 release (API version 45.0), you can build Lightning components using two programming models: the Lightning Web Components model and the original Aura Components model.

你可能感兴趣的:(Salesforce学习)