4d1029dbdb
- Theory assignments - Notes - Practical - Question Papers - DISCLAIMER and motto files Lastly, updated README. Stored using LFS: - Practical/Assignment-1/AWS EC2 - User Guide.pdf - Practical/Assignment-3/Bank-App-Demo.mp4 - Practical/Assignment-3/Demo-3.mp4 - Practical/Assignment-3/Salesforce Apex - Reference Guide.pdf
1.2 KiB
1.2 KiB
Steps for using Apex to create new accounts in Salesforce (for Developers)
This file contains instructions for Assignment-3.
Code
In the Developer Console, after creating a new Apex Class with the name user, paste the below code:
public class user {
public static void createAccount(String accountName) {
// Create a new Account instance
Account newAccount = new Account();
newAccount.Name = accountName;
// Insert the Account into the database
try {
insert newAccount;
System.debug('Account created with Id: ' + newAccount.Id);
} catch (DmlException e) {
System.debug('Error creating account: ' + e.getMessage());
}
}
}
Execution
- In the Developer Console itself, after pasting the above code, press
Ctrl+Sto save the changes, then - Press
Ctrl+Eto open execute anonymous window, - Paste the below content and hit
Execute.
user.createAccount('Test-1');
user.createAccount('Test-2');
Tip
Visit
Accountssection from App Launcher to view the changes.
Note
For account deletion, you have to do it directly from the
Accountssection in App Launcher.