Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create Salesforce objects and fields

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to create Salesforce objects and fields". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to create Salesforce objects and fields.

One. Object

An instance of a class is called an object. As far as Salesforce is concerned, an object can be a class or an object of sObject.

Salesforce provides many functions by default, which can be used for sales, market development, customer service, and so on. To achieve these functions, Salesforce provides a series of standard objects, such as "Account", "Case", "Solution", and so on. You can also create custom objects.

Objects can be thought of as tables in a database.

Whether it is standard objects or custom objects, Salesforce provides a complete interface for them by default to help users create, edit, store and browse.

Create an object from a class

/ / Sample Class Examplepublic class MyClass {Integer myInteger = 10; public void myMethod (Integer multiplier) {Integer multiplicationResult; multiplicationResult=multiplier*myInteger; System.debug ('Multiplication is' + multiplicationResult);}}

This is an instance class, that is, a variable or method of this class is called or accessed, and an instance of this class must be created, and then all operations can be performed.

/ / Object Creation//Creating an object of classMyClass objClass = new MyClass (); / / Calling Class method using Class instanceobjClass.myMethod

SObject creation

SObjects is the object used to store data in Salesforce. For example, accounts, contacts, and so on are custom objects. You can create object instances of these sObject.

/ / Execute the below code in Developer console by simply pasting it//Standard Object Initialization for Account sObjectAccount objAccount = new Account (); / / Object initializationobjAccount.Name = 'Testr Account'; / / Assigning the value to field Name of AccountobjAccount.Description =' Test Account';insert objAccount;//Creating record using DMLSystem.debug ('Records Has been created' + objAccount); / / Custom sObject initialization and assignment of values to fieldAPEX_Customer_c objCustomer = new APEX_Customer_c (); objCustomer.Name = 'ABC Customer';objCustomer.APEX_Customer_Decscription_c =' Test Description' Insert objCustomer;System.debug ('Records Has been created' + objCustomer)

Static initialization

Static methods and variables are initialized only once when the class is loaded. Static variables are not transferred as part of the view state of the Visualforce page.

/ / Sample Class Example with Static Methodpublic class MyStaticClass {Static Integer myInteger = 10; public static void myMethod (Integer multiplier) {Integer multiplicationResult; multiplicationResult=multiplier*myInteger; System.debug ('Multiplication is' + multiplicationResult);}} / / Calling the Class Method using Class Name and not using the instance objectMyStaticClass.myMethod

Static variable usage

Static variables are instantiated only once when the class is loaded, which can be used to avoid triggering recursion. The static variable value will be the same in the same execution context, and any class, trigger, or code that is executing can reference it and prevent recursion.

Two. Field

Each Salesforce object contains several fields (Field). Fields can be thought of as columns in a database table.

Three. System default field

For each object, the system creates several default fields, namely:

ID field (Id)

Creation date field (CreatedDate)

Creator field (CreatedById)

Last modified date field (LastModifiedDate)

Finally modify the person field (LastModifiedById)

System timestamp (SystemModStamp)

These fields are read-only to the user, and only the system itself can modify them.

ID field

By default, Salesforce provides an ID value for each record of each object as a unique identifier for this record throughout the system.

These ID can be expressed in two forms:

15 characters and case sensitive

18 characters and case-insensitive

Users can browse any record by adding the value of record ID directly after the basic URL.

Custom field

Users can add custom fields to each object. Custom fields include a variety of types, such as automatic numbering, dates, numbers, email, text, lookup relationships, URL, and so on.

Related functions of objects and fields

Some features are provided for objects and fields in Salesforce:

Formula: for each object, you can create a series of formulas and output the corresponding results through the logical judgment of the field and the function.

Verification: users can establish verification rules for each object, which can be used to verify whether the user's modifications meet the requirements after the object has been created or edited. If it does not match, the changes cannot be saved. Formulas can be used as part of validation rules

Trigger: trigger is a special Apex class (Apex is the default development language and syntax is similar to Java). When an object is created, modified, or deleted, the functions in it are executed automatically.

Label: a label is a set of descriptive text that describes an object or field

At this point, I believe you have a deeper understanding of "how to create Salesforce objects and fields". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report