• Kevin Caballes 10
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am attempting to save the following but keep getting the error:

Error: Compile Error: Variable does not exist: Send_Attachment_Notification_Email__c at line 20 column 17

The API name for the field on the opportuity object is Send_Attachment_Notification_Email__c so I am not sure what I could be doing wrong.
 
trigger attachmentTrigger on Attachment (before insert) {
    // 1. Get List of Object Ids you wish to notify on
    Set<Id> objectIds = new Set<Id>();
    
    // 2. Loop through list of attachments, and if attachment is associated to object you want to notify on, add Parent Id to objectIds set
    for(Attachment a:trigger.new){
        String keyPrefix = string.valueOf(a.ParentId).substring(0, 3);
         
         if(keyPrefix == '500'){
            objectIds.add(a.ParentId);
         }
    }
    
    // 3. Get your objects you want to notify on, and set the Send Attachment Notification Email field to True 
        // This will to fire the workflow rule to send the email
    if(objectIds.size() > 0){
        List<CASE> yourObjectList = [SELECT Id FROM CASE WHERE Id IN :objectIds];
        
        for(CASE obj:yourObjectList){
            obj.Send_Attachment_Notification_Email__c = TRUE;
        }
        
        if(yourObjectList.size() > 0){
            update yourObjectList;
        }       
    }
}

 
Hi Everyone,

I am trying to add a VF page to pull in my opportunity products onto caess records and I have attempted the following but keep getting the error "Error: Case_Opportunity_Product_List line 31, column 13: XML document structures must start and end within the same entity"

It looks like I am starting and endings with <apex:page> and </apex:page>, so not sure of the problem
 
<apex:page>
Controller-------
public class OpportunityProductList{
    public List<OpportunityLineItem> listOpptyProduct{get;set;}
    public OpportunityProductList(ApexPages.StandardController con){ 
        Case cs = [Select Opportunity__c from Case where Id=:con.getid()];
        listOpptyProduct = new List<OpportunityLineItem>([Select Id, Product2.Name, ServiceDate, UnitPrice from OpportunityLineItem
                    Where OpportunityId=:cs.Opportunity__c]);    
    }
}

Page-------
<apex:page standardController="Case" extensions="OpportunityProductList">
<apex:form >
<apex:pageBlock >
<apex:PageBlockTable var="oli" value="{!listOpptyProduct}">
<apex:Column headerValue="Product Name">
<apex:outputLink value="/{!oli.id}" target="_blank">{!oli.Product2.Name}</apex:outputLink>
</apex:Column>
<apex:Column headerValue="Sales Price">
<apex:outputLabel value="{!oli.UnitPrice}"/>
</apex:Column>
<apex:Column headerValue="Service Date">
<apex:outputText value="{0,date,MM'/'dd'/'yyyy}">
<apex:param value="{!oli.ServiceDate}" />
</apex:outputText>
</apex:Column>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 
I am attempting to save the following but keep getting the error:

Error: Compile Error: Variable does not exist: Send_Attachment_Notification_Email__c at line 20 column 17

The API name for the field on the opportuity object is Send_Attachment_Notification_Email__c so I am not sure what I could be doing wrong.
 
trigger attachmentTrigger on Attachment (before insert) {
    // 1. Get List of Object Ids you wish to notify on
    Set<Id> objectIds = new Set<Id>();
    
    // 2. Loop through list of attachments, and if attachment is associated to object you want to notify on, add Parent Id to objectIds set
    for(Attachment a:trigger.new){
        String keyPrefix = string.valueOf(a.ParentId).substring(0, 3);
         
         if(keyPrefix == '500'){
            objectIds.add(a.ParentId);
         }
    }
    
    // 3. Get your objects you want to notify on, and set the Send Attachment Notification Email field to True 
        // This will to fire the workflow rule to send the email
    if(objectIds.size() > 0){
        List<CASE> yourObjectList = [SELECT Id FROM CASE WHERE Id IN :objectIds];
        
        for(CASE obj:yourObjectList){
            obj.Send_Attachment_Notification_Email__c = TRUE;
        }
        
        if(yourObjectList.size() > 0){
            update yourObjectList;
        }       
    }
}