Saturday, 8 February 2020

How to Query Multiple Child Objects in Single Query


Test 3 is Parent,Test1 and Test 2 have Lookup relation to Test 3

[select id,name,(select id,name from test1s__r),(select id,name from test2s__r) from test3__c]
 Standard Object As Example:
SELECT id,(SELECT Id,Status,CaseNumber FROM Cases),(SELECT Id,Name FROM Contacts) FROM Account

Saturday, 30 November 2019


                         SFDC Interview Questions


                                                               Part 1:

Basic Interview Questions:

Visual force Page:

1. Different type of controller?
2. Difference between controller & Extension Controller?
3. Ajax functionalities?
4. How to avoid view state?Max size?
5. Usage of Apex:param?
6. Page block Table v/s data Tabe?
7. Usage of standard setController?
3.Why do we need pagination?

Triggers:

1. Types of Triggers?
2.Trigger Events?
3.Trigger Context Variables?
4.Trigger.new and trigger.old map?
5.When to use batch class?future class?Que able class?  (Along with syntax)


Point and click Operations:

1.Object Level Permission?
2.Record Level permissions?
3. work flow v/s process builder?
4.Custom setting v/s custom met data type?
5.Types of custom settings?
6.Different types of Reports?


Lightning Components:

1. Different types Lightning events?
2. Global value providers in Lightning components?
3. Usage of Lightning data service?
4. Lazy data Loading?
5.Whats the use of design Token?
6. Render component in Lightning?
7.aura:if v/s aura:renderif

Apex Classes:

1. Apex class best practices
2. Test class best practices?
3. Usage of Test.start Test & Test.stopTest?
4.Governor Limits
5.Order of execution in sales force?
6.with sharing v/s without sharing ?
5. system mode v/s user mode?

Lightning Web Components:

1.Different types of Lightning events?
2. How to integrate child component in parent components?
3.How to call server side action in lwc?
4. LWC best practices?

Integration

1.Different types of WSDLs?
2.Different types of authentication?
3.HTTP methods?
4.Different types of APIs?





















 



Monday, 11 November 2019

                                        Lightning Web Component  Decorators:

@track

It will keep track of the property’s value changes. This decorator is used to make a property private and which helps to re-render the component when the property value is changed.

@api

It is used to expose the public property of a web component. this property can use in it's parent component.

@wire

To access Salesforce data (calling an apex method), Lightning web components use a reactive wire service.


                                                                                                                                               .

Wednesday, 6 November 2019

                              Developer Console is not loading

Most of the time we will face above error,for resolving that error please follow below steps (Provided by Salesforce):
1. login and open Developer Console by Chrome
2. open Developer tools and select Network
3. reload on Developer Console
Use the following query to get the IDEWorkspace
/services/data/v31.0/tooling/query/?q=SELECT id, name from IDEWorkspace
and you would get Id: 1de1a0000014sEWAAY
IsDeleted: false
CreatedDate: 2015-06-18T22:02:05.000+0000
CreatedById: 0051a000000K7Y7AAK
LastModifiedDate: 2015-06-27T01:41:37.000+0000
LastModifiedById: 0051a000000K7Y7AAK
SystemModstamp: 2015-06-27T01:41:37.000+0000
UserId: 0051a000000K7Y7AAK
Name: Default
Content:
ID of IDEWorkspace is "1de1a0000014sEWAAY".
4. login to Workbench and go to REST Explorer
5. do GET for "/services/data/v29.0/tooling/sobjects/IDEWorkspace/1de1a0000014sEWAAY" You will see the content of IDEWorkspace 6. do DELETE
7. re-open Developer Console
You will see an error. And you will see that menus are available.
8. Create a new workspace as the old workspace as been deleted Then, Developer Console will work fine
.



Friday, 26 July 2019

          Cache control value control in a static resource:


Private- It specifies static resource data cached on the Salesforce server shouldn’t be shared with other users. The static resource is only stored in cache for the current user’s session.

Public specifies that the static resource data cached on the Salesforce server be shared with other users in your organization for faster load times.

https://salesforce.stackexchange.com/questions/9038/what-does-the-cache-control-value-control-in-a-static-resource

           System.ListException: List index out of bounds error

Before referring to the 0th index of list you must perform a check on whether the list is empty or not. Whenever you try to access records from list first check if its empty or not.

List <contact>contactList = [Select Id, Name from contact Limit 10];
// Before processing the list check if its empty or not
// It will go inside the loop only if the List is having values in it.
if(contactList.size() > 0) {
 // Do something with contactList [0].Name
 }
// If you try to access contactList [0] without empty check then it will obviously throw that error!!


Saturday, 20 July 2019

Can we write SOSL statements in triggers


Yes, we can write SOSL inside triggers.There is no such restriction.

Code:

trigger trg_AccountSOSL on Account (before insert, before update) {

List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];
List<account> myAcc = ((List<Account>)searchList[0]);

system.debug(myAcc[0].name);
}


UNABLE_TO_LOCK_ROW unable to obtain exclusive access to this record or 1 records


Solution:

When you have multiple jobs running that update the same set of records, it's recommended to lock the records using the FOR UPDATE keyword. 

It will ensure that the record is locked and no other job can update the same record at that point in time. The conflicting job will then wait until the locking on the record is released and then perform the required operation. 

This will avoid conflicts between jobs that are running concurrently and will not throw up this exception. 


You can refer the below link to learn more about record locking.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm

Thursday, 11 July 2019

                                   Organization Administration Locked…?
we will face the above error Message.while saving the classes(sometimes)
This usually means:
  1. Something is being deployed via API (check Setup -> Monitor Deployments)
  2. Something is being deployed via change sets (Setup -> Deploy -> Inbound change sets)
  3. You're running some unit tests

Saturday, 9 February 2019

How to Play YouTube Video In Salesforce Lightning Component


We can play video file in lightning component by 2 ways :


  • From Static Resources.
  • Play Video File Using iFrame Tag.
<aura:component>

  <iframe width="720" height="480" src="https://www.youtube.com/embed/45JRuZOBIKk"></iframe>

</aura:component>


<aura:application>
    <c:videoDemo/>
<!-- here c: is org. default namespace prefix-->
</aura:application>


Referred Blog:

http://sfdcmonkey.com/2017/06/06/play-youtube-video-lightning-component/

How To Detect a Device In Salesforce Lightning Component ?


{!$Browser.isTablet}      > To detect the tablet device
{!$Browser.isPhone}      > To detect the user is in Mobile Phone / mobile browser
{!$Browser.isAndroid}   > To detect the user is in Android device
{!$Browser.formFactor} > Returns a FormFactor enum value based on the type of hardware the browser is                                                            running on.


DetectDevice.cmp

<aura:component>

    <aura:if isTrue="{!$Browser.isTablet}">
    You are using a tablet device
        ( <lightning:icon iconName="utility:tablet_portrait" size="x-small" alternativeText="Indicates approval"/> ).
    </aura:if>
    <aura:if isTrue="{!$Browser.isPhone}">
        You are using a phone
        ( <lightning:icon iconName="utility:phone_portrait" size="x-small" alternativeText="Indicates approval"/> ).
        This message is rendered using isPhone <br />
    </aura:if>
    <aura:if isTrue="{!$Browser.isIPhone}">
        You are using an IPhone, If it is IPhone X, _/\_ <br />
    </aura:if>
    <aura:if isTrue="{!$Browser.formFactor == 'DESKTOP'}">
    You are using a DESKTOP
        ( <lightning:icon iconName="utility:desktop" size="x-small" alternativeText="Indicates approval"/> )
        Browser device
    </aura:if>
    <aura:if isTrue="{!$Browser.formFactor == 'PHONE'}">
    You are using a Phone, This message is rendered using formFactor
    </aura:if>
    <aura:if isTrue="{!$Browser.formFactor == 'TABLET'}">
    You are using a Table device
    </aura:if>
</aura:component>


<aura:application extends="force:slds">
    <c:DetectDevice />
</aura:application


var device = $A.get("$Browser.formFactor");

               How to Find Salesforce Object ID prefixes (custom or standard)

If you want to check for standard object replace customObject__c with standardObjectName
system.debug('Prifix–> ' + customObject__c.sobjecttype.getDescribe().getKeyPrefix());


Saturday, 2 February 2019

                                     DATALOADER:






A. Log In Issues: Are You Timed Out?

If you leave the Data Loader running on your machine, it will time out in the number of seconds you have defined in the Settings:If the Data Loader has timed out, and you try to perform another operation with it, you will receive a message like this one:
The message looks a bit ominous, and if you are seeing it for the first time

B. Are you logging into sandbox or production?-check server host url properly(https://test.salesforce.com for a sandbox org and https://login.salesforce.com for a production org)

C.Log In Issues: Do you need a security token?

Unless your IP address is trusted by the Salesforce org you are trying to log into, you will need to add your security token to the end of your password in order to log into the Data Loader.

Keep track of your security tokens – you need one for each production org and each sandbox org for which your IP address is not trusted.

Either add your security token to the end of your password string, or trust your IP address. Be careful trusting IP addresses – doing so reduces the protection on your Salesforce org.

To trust your IP address, obtain the IP address from your system. Then, in Salesforce, under Administration Setup => Security Controls =>Network Access, enter your IP Address as the Start IP Address and End IP Address, or enter a range that includes your IP Address.


Loading Null Values into Fields

Sometimes you may need to use the Data Loader to “null out” a value and load blank values for one field for one or more records.

In the Data Loader, select Insert null values. It is recommended that you only select this option when you specifically intend to insert null values. 

Don’t leave it selected because you may inadvertently erase data if you map a blank column to a field when you are data loading.


Loading Data When Same Record is Updated More than Once

The Data Loader limits the number of records you can update with an upsert in the same batch. If you try to upsert the same record more than time in the same batch, you will receive an error message like one of the following:

duplicate value found: unknown duplicates value on record with id: a044000000HpfNS

Duplicate external id specified: 12345


Depending on the situation, the data you are trying to load may need to be analyzed, for example, to determine the most recent update, or some other criterion of precedence.

However, if you know that all the upserts need to be loaded, you can eliminate this obstacle by reducing the Data Loader batch size to one. Each record will then load, regardless of whether that record was already upserted earlier in the data load.


Show All Salesforce Objects

The Data Loader defaults to showing the most common standard objects and your org’s custom objects when you insert/update/upsert/delete/export.

However, there are other objects that you can access by selecting Show all Salesforce objects when you begin your data loader operations.

Using Data Loader to Write SOQL Queries

When you delete/export Salesforce records using the Data Loader, you are performing a SOQL query. The generated query appears at the bottom of the Data Loader dialog. Add filters to the query by first selecting from the fields in object you are querying, and then selecting an operation and choosing a value.

Account: id value of incorrect type: #N/A

This example error is for the Account object, but where the error reads “Account,” it could be any standard or custom Salesforce object. The word(s) after the colon in this error refer to what was found in the column mapped to the Account ID – in this case, the column for Account read “#N/A.” This value is typical of using a vlookup function in Excel to build your data load file and getting no results for this row.

There is no way to update a Salesforce record without its Salesforce ID. If you have values for another field on the object that is defined as a foreign key (or “unique identifier” in Salesforce), you can use that field to upload data, but you have to perform an upsert.

Error converting value to correct data type: Failed to parse date: N/A

Error converting value to correct data type: Failed to parse date: 00:00.0

The above are two examples of errors when the data being mapped is not of the correct format for the date field to which it is being mapped. You can tell by what follows the colon in the error; this is what the Data Loader is finding and trying to map to a date. See above for help with Date/Time format.

Insufficient access rights on cross-reference ID

Insufficient access rights messages pertain to the owner of the record that is being modified. So, if you are loading an owner ID (using the Salesforce ID of someone’s User record), then that person has insufficient access (permission) to what you are trying to insert or update.

If you are not loading an Owner ID for the records, then you (the user logged into the Data Loader) do not have permission to insert or update. If you are a System Admin, check for the following:

An unassigned record type for the object (it must be one of the record types for that object that is assigned to your profile in order for you to be able to create records of that record type)
An inactive record type for the object
A field that it is read-only for the System Admin profile (it may be read-only for all profiles)
Similarly, if you see this error:

Record Type ID: this ID value isn’t valid for the user

Check to make sure:

Is it active?
Does the record owner’s profile have access to the record type?
Is the ID correct for record type – no typos, or other errors in the string?
Invalid cross-reference ID

This error is related to the other ID errors. It indicates that you are trying to load some value (or a blank value) for an external ID for a custom object that does not exist for any record in that object. For example, trying to load a reference to Contact with “9013133” as a Student_ID__c (where Student_ID__c is defined as a unique external ID for Contact) when you don’t have a Contact in your org with that Student_ID__c value.

It is also possible that the user performing the load does not have access to the Student_ID__c field (in the example). To check on this second possibility, manually try to access one of the Contact records with one of the Student_ID__c values that is giving this error, such as by building a view of Contacts with Student_ID__c = “9013133” (which should return exactly one Contact if you have access to the field and that value exists for one of the Contact records.

npe01.IndividualAccounts: execution of BeforeInsert

Any error message that references BeforeInsert, BeforeUpdate, or another Apex operation is most likely being triggered by some existing code in your organization. Review the code base for the object to which you are trying to insert or update records.

If there is a Foreign Key, you must include a Legacy System ID.

Sometimes the error is caused by existing validation rules in your Salesforce org. To recognize such errors, use consistent language for your validation rule error messages and if you need to be able to load data – for example, legacy data – that does not have to be consistent with validation rules, consider making an exception to the validation rule, such as a Custom Setting that keeps it from running when the user is the System Administrator.



Links:

https://www.salesforcetutorial.com/salesforce-data-loader/