function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Remedy_MorrisRemedy_Morris 

Problem with Custom Components on an Email Template

Hi,

Can anyone help ? I think there should be a simple resoultion.

I've created the following email template / component :

<messaging:emailTemplate subject="Incident #{!relatedto.Name} (Ref:IN:{!relatedto.Name})" recipientType="User" relatedToType="BMCServiceDesk__Incident__c">
<messaging:htmlEmailBody >

<c:MyComponent Inc_Id="{!RelatedTo.BMCServiceDesk__incidentId__c}" />
   
<html>
        <table>
         <b><font size="4" color="#4181FF" face="Arial">Update Information</font></b><br>    
         <apex:component controller="RepeatCon" access="global">
              <apex:attribute name="incidentId" type="String" description="Remedy Incident ID" assignTo="{!Inc_Id}" >
                   <apex:repeat var="cx" value="{!getNotes}">
                       <tr>             
                          <td><font face="Arial">{!cx.BMCServiceDesk__note__c}</font></td>
                       </tr>       
                  </apex:repeat>         
       </table>
    </body>
    </head>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

I've cretaed the following controller:

public class RepeatCon {
    
    public String incidentId {get;set;}
    List<BMCServiceDesk__IncidentHistory__c> notes;

    public List<BMCServiceDesk__IncidentHistory__c> getNotes() {
        notes = [SELECT BMCServiceDesk__note__c, BMCServiceDesk_Sequence_c__c FROM   BMCServiceDesk__IncidentHistory__c  
        WHERE BMCServiceDesk__incidentId__c =:incidentId];
            
        return notes;      
        }
      }

I keep getting the following error message :

 Error: Component c:mycomponent does not exist

 

I've searched through all the previous discussions and I can't find an answer.

Does anyone have any ideas ?


Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

just check the name of the component once and also check whether the component attribute access="global" or not..

Any <apex:component> tags used within a Visualforce email template must have an access level of global.

All Answers

kiranmutturukiranmutturu

just check the name of the component once and also check whether the component attribute access="global" or not..

Any <apex:component> tags used within a Visualforce email template must have an access level of global.

This was selected as the best answer
Remedy_MorrisRemedy_Morris

Thanks for the response. I've checked and the only component I have is :

<apex:component controller="RepeatCon" access="global" name="MyComponent">
              <apex:attribute name="incidentId" type="String" description="Remedy Incident ID" assignTo="{!Inc_Id}" access="global">
                   <apex:repeat var="cx" value="{!getNotes}">
                       <tr>
               
                          <td><font face="Arial">{!cx.BMCServiceDesk__note__c}</font></td>
                       </tr>
        
                  </apex:repeat>
  </apex:component>          

This is set to access="global" and I'm getting the same error.

I am calling  <c:MyComponent Inc_Id="{!RelatedTo.BMCServiceDesk__incidentId__c}" access="global" />

VisualForce doesn't seem to recoginise 'MyComponent', do I need to write another component for 'MyComponent' for example:

  <apex:component controller="RepeatCon" access="global" id="MyComponent" >
             <apex:attribute name="incidentId" type="String" description="Remedy Incident ID" assignTo="{!Inc_Id}" access="global">
          </apex:component>

Remedy_MorrisRemedy_Morris

Ok, I've worked out what the problem is.

A school boy error. I didn't define the component correctly.

Issue resolved.

Nuevo9763Nuevo9763
@Remedy_Morris,
may I know what was the issue? I am facing similar issue.
Thanks,