Author Archives: Biswajeet

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.

Partial Apex DML Example in Salesforce

List <Account> conList = new List <Account> {
 new Account(Name = 'Test Account1', Phone = '8888888888', Industry = 'Agriculture'),
 new Account(Name = 'Test Account2', Phone = '7777777777', Industry = 'Banking'),
 new Account(Name = 'Test Account3', Phone = '9999999999', Industry = 'Finance'),
 new Account()

Database.SaveResult[] srList = Database.insert(conList, false);

for (Database.SaveResult sr : srList) {
 if (sr.isSuccess() ) {
  //Develop code for successfully inserted Accounts
  System.debug('Successfully inserted Account ' + sr.getId());
 } else {
  for (Database.Error err : sr.getErrors()) {
   //Develop code for failed Accounts
   System.debug(err.getStatusCode() + ' : ' + err.getMessage() + ' : ' + err.getFields());

Convert sObject to JSON String and JSON String to sObject Using Apex in Salesforce

Sample Code:

Account acc = new Account(Name = 'Account Name', Phone = '8888888888', Industry = 'Agriculture');
//Code to convert Account to JSON string
String str = JSON.serialize(acc);
system.debug('Account JSON Data - ' + strJSON);
//Code to convert JSON string to Account
Account acc1 = (Account)JSON.deserialize(str, Account.Class);
system.debug('Account Data - ' + acc1);


Set Default Value in Picklist in Lightning Component

Here in below example the default value in picklist is “Apple”.
Lightning Component:

    <ui:inputSelect aura:Id="brandId" multiple="false" label="Select Brand">
        <ui:inputSelectOption label="Apple" text="Apple" value="true"/>
        <ui:inputSelectOption label="Nokia" text="Nokia"/>
        <ui:inputSelectOption label="Samsung" text="Samsung"/>
        <ui:inputSelectOption label="Google" text="Google"/>
        <ui:inputSelectOption label="Mi" text="Mi"/>