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.

How to Lock records using Apex in Salesforce?

Using UPDATE keyword in SOQL helps us to lock the records from being updating from another request.

Sample Code:

Account [] objAccts = [SELECT Id, Name FROM Account where Country='India' FOR UPDATE];

Note: We can’t use the ORDER BY keywords in any SOQL query that uses locking.

Difference between Unmanaged Package and Managed Package in Salesforce

Unmanaged Package:

  • Unmanaged packages are typically used to distribute open-source projects or application templates to provide developers with the basic building blocks for an application.
  • Once the components are installed from an unmanaged package, the components can be edited in the organization they are installed in.
  • The developer who created and uploaded the unmanaged package has no control over the installed components, and can’t change or upgrade them.
  • Unmanaged packages should not be used to migrate components from a sandbox to production organization. Instead, use Change Sets.

Managed Package:

  • Managed packages are typically used by partners to distribute and sell applications to customers.
  • Once the components are installed from a managed package, the components cannot be edited in the organization they are installed in.
  • Managed packages are also fully upgradeable.
  • To ensure seamless upgrades, certain destructive changes, like removing objects or fields, can not be performed.

How to get a RecordType Id by Name without SOQL?

Sometimes in apex we required RecordType Id of an object by its Name. So, here is an example how we can find RecordType Id by Name.

In below example BankAccount__c is the custom object and “Savings Account” is one of the RecordType Name of BankAccount__c object. Now without SOQL I’ve to find “Savings Account” RecordType Id.

String recordTypeName = 'Savings Account';