Search This Blog

Thursday, September 22, 2022

Install Java and setup java path

Step 1: Download the java from the link 

https://www.oracle.com/java/technologies/downloads/

Downloaded x64 for windows.

Step 2: Install java by double clicking the file downloaded.

Step 3:Setup java path

Open the folder where java is installed and copy the url till bin folder.

Go through the image for reference.

C:\Program Files\Java\jdk-19\bin

Now right click on Computer --> properties --> Advanced system settings --> Environment Variables --> new -->

Enter variable name as "JAVA_HOME" and in variable value, paste the java url which you copied. and then click ok.

Now open the command prompt and run javac command.If you get below response,then it means that you have set java path correctly.



Thursday, September 15, 2022

difference() of String class in apex Salesforce

 The difference() returns the difference between the current String and the specified String.

Example:

String str1 = 'Hello Suresh';

String str2 = 'Hello Mahesh';

String difference = str1.difference(str2);

system.debug('Difference : '+difference);

Output:

Note: It's case sensitive.

Query profile in Salesforce - Salesforce Globe For You

Solution: Use the below query to fetch profile in salesforce

SELECT name,UserType,Description from Profile

Output:



Query custom labels in Salesforce - Salesforce Globe For You

Solution: Use the below query by making sure tooling API is enabled

SELECT name,value from ExternalString

Output:



Wednesday, September 14, 2022

Query to fetch the apex class in salesforce - Salesforce Globe For You

Solution: Use the below SOQL query to fetch the apex classes

select Name,status,LengthWithoutComments,Body,APiversion,createddate from ApexClass

Output:



Friday, September 2, 2022

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field salesforce

Problem: This error generally occurs when you are using a field in the logic without quering that field in its related SOQL query.

Example:

Account a = [Select id,name from Account limit 1];

if(a != null) {

    if(a.rating =='Cold') {

        System.debug('Rating is Cold');

    }  

}

In the above code, line 3 rating field is referred but it's not queried in the soql query at line 1.

Updated Code:

Account a = [Select id,name,rating from Account limit 1];

if(a != null) {

    if(a.rating =='Cold') {

        System.debug('Rating is Cold');

    }  

}

Output:



Reverse a string in apex salesforce

Solution: Use reverse() to reverse a given string

Example:

String blog ='Salesforce Globe For You';

System.debug('Reverse :'+blog.reverse());

Output:



Get salesforce instance name

Solution: Use the following query on Organization object to get the instance name

select instancename from Organization

Output:



Get salesforce OrganizationType

Solution: Use the following SOQL on the organization object to know the organization type.

select organizationtype from Organization

Output: