You need to sign in to do that
Don't have an account?
Nandhini S 3
DML Exception
Hi Team,
I'm checking if my list is empty before the update. My list returns null but still the If condition is resulting true and DML statement is throwing error.
If(myList != null && !myList.isempty())
{
update myList;
}
What am i doing wrong here
I'm checking if my list is empty before the update. My list returns null but still the If condition is resulting true and DML statement is throwing error.
If(myList != null && !myList.isempty())
{
update myList;
}
What am i doing wrong here
Greetings!
The list should be initialized to use isEmpty() otherwise you can use myList.size()>0 to check,if the list is empty or not.
Reference:https://salesforce.stackexchange.com/questions/77173/list-isempty-vs-list-size-0-vs-list-null/77200
Please mark it as best answer if it helps you to fix the issue.
Thank you!
Regards,
Shirisha Pathuri
My code goes something like this
List<Project__c> myList = new List<Project__c>();
for(project__c proj: newList)
{
project__c thisProject = new project();
if(some condition)
{
some field assignments
}
myList.add(thisProject);
}
if(myList.size()>0)
{
update myList;
}
My if condition is not satisfied and there is nothing in the myList but when i check the size it shows 1.