Play Games

Search This Blog

Thursday, April 28, 2022

Single SOQL query to query Opportunity and Opportunity line items together in salesforce - Salesforce Globe For You

Single SOQL query to query Opportunity and Opportunity line items together in salesforce - Salesforce Globe For You

Solution: Use the following SOQL query.

SELECT id,Name,(Select id,Name,Quantity from OpportunityLineItems) from Opportunity

Example: Run the following piece of code in developer console.

List<Opportunity> lstOpportunity = new List<Opportunity>();

lstOpportunity = [SELECT id,Name,(Select id,Name,Quantity from OpportunityLineItems) from Opportunity];

system.debug('List of Opportunities: '+lstOpportunity);

Output:



Single SOQL query to query Quote and quote line items together in salesforce - Salesforce Globe For You

Solution: Use the following SOQL query.

SELECT id,Name,QuoteNumber,Status,(Select id,LineNumber,ServiceDate,QuoteId,Quantity from QuoteLineItems) from Quote

Example: Run the following piece of code in developer console.

List<Quote> lstQuote = new List<Quote>();

lstQuote = [SELECT id,Name,QuoteNumber,Status,(Select id,LineNumber,ServiceDate,QuoteId,Quantity from QuoteLineItems) from Quote];

system.debug('List of Quotes: '+lstQuote);

Output:



Thursday, April 21, 2022

How to convert string to an array in Apex - Salesforce Globe For You

How to convert string to an array in Apex - Salesforce Globe For You

Solution: Use split('') to convert string to array.

Example: Run the following piece of code from anonymous window of developer console

List<String> lstCharacter = new List<String>();

String str = 'Salesforce Globe For You';

lstCharacter = str.split('');

system.debug('String Array: '+lstCharacter);

Output:



How to find the length of a string in Apex - Salesforce Globe For You

How to find the length of a string in Apex - Salesforce Globe For You

Solution: Use the length() to return the number of characters in the string.

Example:

Run the following piece of code from anonymous window of developer console

String str = 'Salesforce Globe For You';

Integer iLength = str.length();

system.debug('Length of the String: '+iLength);

Output:



Friday, April 15, 2022

How to copy all the picklist values of a field in salesforce - Salesforce Globe For You

How to copy all the picklist values of a field in salesforce - Salesforceglobe4u

Solution: Using 'Printable View' button,we will be able to copy all the values of a picklist field.

Example: Here we will be coping Industry picklist field values of Lead object

Go to Setup --> object Manager --> Lead --> Fields & Relationships --> Industry --> Industry picklist values 

click on 'Printable View' button as shown in the image below


copy all the values and save them.



Wednesday, April 13, 2022

How to enable or setup multiple currencies in Salesforce - Salesforce Globe For You




Note: Once you enable multi currencies, you cannot disable it. Keep it in mind.

Solution: Go to Setup -->Company Settings --> Company Information --> click on Edit button
Select the checkbox next to Activate Multiple Currencies field in the Currency Settings section as shown in the image below.



Once its enabled, in the company information page, you can find the 'Currency Setup' button to configure multiple currencies.



Tuesday, April 12, 2022

How to identify which edition of salesforce(Enterprise/Unlimited/performance/Developer) is your salesforce instance - Salesforce Globe For You

Solution: There are 2 ways in salesforce to get the Salesforce Edition information.

Option1: Go to Setup --> Company Settings --> Company Information


In the Organization Edition field as shown in the image above, you can see the salesforce edition.

Option2: Using SOQL query on Organization object as shown below

select OrganizationType from Organization

Friday, April 8, 2022

How to know the details about user licenses in salesforce org - Salesforce Globe For You

How to know the details about user licenses in salesforce org - Salesforce Globe For You

Solution: There are 2 ways to know the user licenses details

solution 1: Go to setup --> Company Settings --> Company Information --> click on User Licenses related list

Here you will be able to see the details

solution 2: Using SOQL query

select id,Name,LicenseDefinitionKey,MasterLabel,UsedLicensesLastUpdated,createddate from UserLicense

Output:



How to pass multiple values or variables from flow(screen element) to invocable method of Apex - Salesforce Globe For You

Solution: You can create wrapper class and use it in the flow.

Example:

Apex Class: ContactCreation

public without sharing class ContactCreation {

    @InvocableMethod(label='create Contact' description='Returns the ContactId')

    public static List<String> createContact(List<ContactWrapper> contactWrap) {

        contact c = new contact();

        c.lastName = contactWrap[0].lastName;

        c.FirstName = contactWrap[0].firstName;

        c.Email = contactWrap[0].contactEmail;

        c.Phone = contactWrap[0].contactPhone;

        insert c;

        List<String> lstContactId = new List<String>();

        lstContactId.add(c.id);

        system.debug('lstContactId:'+lstContactId);

        return lstContactId;

    }

    public class ContactWrapper {

        @InvocableVariable

        public String firstName;

        @InvocableVariable

        public String lastName;

        @InvocableVariable

        public String contactEmail;

        @InvocableVariable

        public String contactPhone;

    }

}

create flow: ContactCreation




output: When you run the flow,the contact record gets created successfully.



Thursday, April 7, 2022

How to view or get callback url from connected app in Salesforce - Salesforce Globe For You

How to view or get callback url from connected app in Salesforce - Salesforce Globe For You

Solution: Go to Setup --> Apps --> App Manager --> click on top right side chevron on the respective app in which you wanted to see callback url and click on view

You will be able to see the callback url as shown in the image below.


Wednesday, April 6, 2022

How to publish platform event from Apex - Salesforce Globe For You

Solution: EventBus.publish() can be used to publish the platform events from Apex

Example: In this example,as soon as account is created, the platform event is fired using account trigger.

Platform Event: Account_Event__e


Account Trigger: AccountObjectTrigger

trigger AccountObjectTrigger on Account (after insert) {

    List<Account_Event__e> lstPlatformEvent = new List<Account_Event__e>();

    for(Account acc:trigger.new) {

        Account_Event__e objEvent = new Account_Event__e();

        objEvent.Account_Id__c = acc.Id;

        lstPlatformEvent.add(objEvent);

    }

    if(!lstPlatformEvent.isempty()) {

        EventBus.publish(lstPlatformEvent);

        System.debug('Event:'+ lstPlatformEvent);

    }

}

Tuesday, April 5, 2022

How to query page layouts associated with an object in salesforce - Salesforce Globe For You

Solution

Use the below query to fetch all the page layouts in the org from Developer console by making 'Use Tooling Api' checkbox to true.

select id,name,EntityDefinitionId,TableEnumOrId from Layout


To query layouts associated with an object use the query below

select id,name,EntityDefinitionId,TableEnumOrId from Layout where TableEnumOrId='Account'

where TableEnumOrId is the enum (for example, Account) or ID of the object this layout is on.

Monday, April 4, 2022

Will the change in the roll up summary field cause trigger to fire in Salesforce - Salesforce Globe For You

Will the change in the roll up summary field cause trigger to fire in Salesforce - Salesforce Globe For You

Answer: Yes. When the roll up summary field value changes,if there is any trigger on that object,the trigger will fire.

Example:

Step 1: created a custom rollup summary field on Account Sum_Of_Opportunities__c which will give sum of all opportunities.


Step 2: create trigger on Account

trigger AccountObjectTrigger on Account (after update) {

    for(Account acc:trigger.new) {

        system.debug('Trigger fired due to roll up summary field change');

    }

}

Step 3: When the opportunity updated,the account trigger fired and gave the output

Trigger fired due to roll up summary field change