You need to sign in to do that
Don't have an account?
Getting Variable does not exist two lines after creating a list variable. Argh.
I just want to iterate through the list I create and set a field stating whether there are attachments on the object to no when conditions are met via a before delete trigger. I'm getitng variable does not exist
if(parentObjId.startsWith('a0x')&& Trigger.isdelete)
List<CRM_Outreach__c> CRMNoList = [select id, Attachment_Added__c from CRM_Outreach__c where id =: Trigger.New[0].ParentId];
// query to see if there are still attachments under the object
// If there were less than two, i.e. 1 attachment, then there will be zero after the after delete trigger.
if(CRMNolist.size()<2){
for (CRM_Outreach__c CRM : CRMNoList)
{
CRM.Attachment_Added__c = 'No';
You are getting this error because the line where you created the list variable is inside the "IF" statement, so it is a local variable. You can overcome this by using the curley braces "{ }" like this: