this ans is for Account a =[SELECT Name FROM Account WHERE industry='Energy']; ---->System.QueryException: List has more than 1 row for assignment to SObject --->reason--> storing list of records into single variable.
@TechJourneyWithAnkit3 ай бұрын
Very good explanation
@gomathihariharan946423 күн бұрын
Ankit, great content. Pls do create a video on the apex replay debugger. It would be really helpful.
@TechJourneyWithAnkit22 күн бұрын
It's already on the channel
@Mucherlasivaji-z4y2 ай бұрын
tqq Ankit sharing informatic videos
@TechJourneyWithAnkit2 ай бұрын
Welcome
@user-jb6cn9ej5m2 ай бұрын
// Collect all Account IDs from the trigger Set accountIds = new Set(); for (Account acc : Trigger.new) { accountIds.add(acc.Id); } // Query all Contacts related to the Accounts in the trigger List conList = [SELECT Id, AccountId FROM Contact WHERE AccountId IN :accountIds]; // Process each Contact for (Contact con : conList) { // Your logic here }
@TechJourneyWithAnkit2 ай бұрын
Very good
@sriharshithareddy71153 ай бұрын
1. DML Exception - Required Field Missing (LastName) 2. QueryException - No records returned or trying to assign more than 1 record to a singleton sObject Account variable.
@TechJourneyWithAnkit3 ай бұрын
Correct
@kaustubhpatne63203 ай бұрын
In 1st scenario Where you iterate over accounts Mistake is that Dml statement used inside for loop So to overcome this use separate list and insert list outside for loop
@TechJourneyWithAnkit3 ай бұрын
Very good
@SalesforceMiind2 ай бұрын
Hi Ankit, 🙌 Kudos to you for all the good work you have been doing! . Could you please create a separate video for "Apex replay debugger" ?
@TechJourneyWithAnkit2 ай бұрын
Sure will plan for it
@ravigrover19233 ай бұрын
DMl Exception: Required Field(Last Name) is mIssing
@TechJourneyWithAnkit3 ай бұрын
Yes correct
@vaibhavchaubey47483 ай бұрын
Thank you sir 🙏
@mohd.arshad13153 ай бұрын
Hi Ankit, You are doing a great job for the community, my request to you is that I can get the list of questions and answers you are preparing in the form of a PDF
@TechJourneyWithAnkit3 ай бұрын
Thanks
@AnbalaganK-g8f3 ай бұрын
It may throw the query exception. More than one record to a singleton sObject variable.
@ravigrover19233 ай бұрын
QueryList Exception : List has no rows exception, store it in a list
@TechJourneyWithAnkit3 ай бұрын
Yes correct
@ravigrover19233 ай бұрын
Set accSet = new Set(); for (Account acc : trigger.new){ accSet.add(acc.Id); // do some processing there } List conList = [SELECT Id,FirstName,LastName FROM Contact WHERE AccountId IN : accSet]; for (Contact con : conList){ // do some processing there }
@TechJourneyWithAnkit3 ай бұрын
Any other better approach Ravi to avoid two loops
@janac75103 ай бұрын
Nice
@awesomekj58123 ай бұрын
Curious ..have you done the video on Apex Replay Debugger ? Also for last question --> will you get LIST HAS NO ROWS FOR ASSIGNMENT TO SObject error ??? And we can fix it by converting that account instance to List
@TechJourneyWithAnkit3 ай бұрын
Not yet, will plan for it.
@vaibhavchaubey47483 ай бұрын
required field is missing in last question , cont.LastName
@TechJourneyWithAnkit3 ай бұрын
Please tell me the name of exception
@rangurajeevkumar16943 ай бұрын
@@TechJourneyWithAnkit System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName]: [LastName]
@naveenyalamala3 ай бұрын
Is it possible to call Batch class from a future call?
@TechJourneyWithAnkit3 ай бұрын
No
@abisheakramasamy58713 ай бұрын
How to get job as freshers in Salesforce developer
@TechJourneyWithAnkit3 ай бұрын
Get admin skills strong and have sound knowledge of Apex and LWC. With overview of Integration
@mr.mrs.khandal96583 ай бұрын
Please create a vedio on apex reply debug.
@TechJourneyWithAnkit3 ай бұрын
Sure I will plan for it
@darshanshanbhag73322 ай бұрын
@@TechJourneyWithAnkit Even I am expecting a video on Apex replay debugger. So, Kindly make a video on that as well. Thanks in Advance
@bbk99883 ай бұрын
Nice video 👍 waiting for the videos on triggers batch apex and other concepts 😊
@kishorey73353 ай бұрын
set accId=new set(); for(Account a:trigger.new){ accId.add(a.Id); } list conlist=[select Id,AccountId from contact where AccountId in:accId]; for(contact con:conlist){ }
@sriharshithareddy71153 ай бұрын
for(Account a : [SELECT Id, (SELECT Id FROM Contacts) FROM Account WHERE Id IN :Trigger.New]{ for(Contacts con : a.Contacts){ //Some contact processing } }
@TechJourneyWithAnkit3 ай бұрын
Correct
@SalesforceMiind2 ай бұрын
@@TechJourneyWithAnkit Nested for loop is not a part of best practices