public class CreateSobject {
public static void newAccount(String accName){
System.debug('Account Creation Check Account Name : '+accName);
// Sobject Account Object Assignment
//
// Data_Type Variable_Name Operator (=) Expression (NEW => Ram memory assigment );
// Account preparation
Account singleAccount = New Account();
singleAccount.Name=accName;
// DML Operation Send to Salesforce Database
insert singleAccount;
System.debug('New Account ID : '+singleAccount.id);
}
public static void newRental(String rentalName,Integer newphone,String newaddress){
System.debug('new rental working');
// Datatype variable name operator expression.
Rental__c newRent = New Rental__c();
newRent.Name=rentalName;
newRent.Phone__c = newphone;
newRent.Address__c=newaddress;
insert newRent;
System.debug('newRent id : '+ newRent.id);
}
}
Generic Vs Standart Sobject
// Standard
// CONTACT ( SOBJECT STANDART OBJECT CONTACT )
// Contact singleSobj =
// [SELECT Id,firstName,lastName, AccountId, Account.Name FROM Contact LIMIT 1];
//System.debug('Account Name : '+ singleSobj.Account.Name);
// System.debug('Account Name : '+ singleSobj.firstName);
// Generic Sobject and methods
SObject singleSobj =
[SELECT Id,firstName,lastName, AccountId, Account.Name, Account.Phone FROM Contact LIMIT 1];
System.debug('firstName Name : '+ singleSobj.get('firstName'));
System.debug('lastName Name : '+ singleSobj.get('lastName'));
System.debug('Account Name: '+ singleSobj.getSObject('Account').get('Name'));
System.debug('Account Phone: '+ singleSobj.getSObject('Account').get('Phone'));