Oct 12, 2024
59 Views
Comments Off on Salesforce Apex Data Manipulation operations
0 0

Salesforce Apex Data Manipulation operations

Written by

Apex Data Manipulation Language(DML) Operations in Salesforce Use Data Manipulation Language (DML) Operations to insert, update, delete, and restore data in a database.We can execute DML Operations using two different forms.

Apex DML Statement, Such asInsert SObject();

Apex DML database methods, such asDatabase.saversult() result=Data Insert(SObject());

—>The following example that inserts a new invoice statement by calling insert and if we execute in the ‘Developer console” that creates a record into the database.

Invoice_Statements_c Inv=new Invoice_statement_c(Description)c=’capital info solutions’);Insert Inv —> Inserting the invoice using DML.

Note:- After the invoice statement is inserted the sobject variable inv will contain the ID of the new invoice statement.

Enthusiastic about exploring the skill set of Salesforce? Then, have a look at the Salesforce Training Course together additional knowledge* The following example shows the creating records through API for Account object using Insert DML Operation.

Account a=new Account(); a.Name=’Osmania University’; a.Phone=’9052—–‘; a.Email-c=’capitalinfosol@gmail.com’, a.Billingcity=’Hyderabad’;

Insert a;—> this means assigning the field values to account recordDML Operation used for inserting a record—-> The following example shows the creating a contact through API using DML operation (Insert)

Contact C= new contact(); C.last name=’Anil’; C.Account id=’XXX’Override any account id here//This means assigning account to a contact

Insert C; Systerm.debug(C)Note:- For custom Objects;

Customer_c C=new customer_c(); C.Name=’Anil’; C.partner_c=’xxxx’;API Name of lookup filed or MD field

Insert c;

Customer__c is child object and partner__c is parent objectNote: while inserting the object records the following notes

Certain SObjects cannot be created to insert an object record because the ”create” permission of the object must be set to trueWe must supply a non-null value for all required fieldsThe “insert” statement automatically sets the ID value of all new subjects recordsWe can pass a maximum of 10,000 SObject records by using a single insert method.

Article Categories:
Fashion
Priya Singh
https://thestarbiznews.com/

Expertise: Technology Trends, Startups, Digital Disruption Bio: Priya Singh is a tech-savvy millennial with a finger on the pulse of the ever-evolving digital landscape. A graduate of Stanford's Computer Science program and a former engineer at a Silicon Valley giant, Priya has a deep understanding of the technologies shaping our future. Her passion lies in demystifying complex tech jargon and exploring the disruptive potential of emerging trends, making her articles essential reading for anyone who wants to stay ahead of the curve. When not scouring the web for the latest tech tidbits, Priya enjoys traveling to off-the-beaten-path destinations and immersing herself in diverse cultures, always seeking new inspiration and insights.