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
ManoharSFManoharSF 

Visualforce email template

Hi there, can some one please let me know whats missing as I dont get the records back for my VF email template?

 

Any help is greatly apreciated.

 

Thanks

Manohar

 

 

<messaging:emailTemplate subject="Deign Package Rejected Reasons" recipientType="Contact" relatedToType="Construction_Package__c">
    <messaging:htmlEmailBody >
        <c:rejectedlist CotId="{!relatedTo.Id}" /><br/><br/>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 componentt name :rejectedlist

<apex:component controller="rejectedlist" access="global">
 <apex:attribute name="CotId" type="Id" description="Id of the Construction Package" assignTo="{!conID}"/>
    <table border = "2" cellspacing = "5">
        <tr>
            <td>Name</td>
            <td>Rejection Reason</td> 
            <td>Suggested Resolution</td>
            <td>Status</td>                
        </tr>
        <apex:repeat value="{!rejectedlist}" var="rl">
        <tr>
            <td>{!rl.Name}</td>
            <td>{!rl.Rejection_Reason__c}</td>     
            <td>{!rl.Suggested_Resolution__c}</td>  
            <td>{!rl.Status__c}</td>           
        </tr>
        </apex:repeat>        
    </table>

</apex:component>

 

public  with sharing class rejectedlist {

    public Id conID {get;set;}
    
    public List<Rejection_Checklist__c > getrejectedlist () {
        list <Rejection_Checklist__c> rejlst;
        rejlst  =   [Select id, Name, Rejection_Reason__c, Suggested_Resolution__c, Status__c  from Rejection_Checklist__c where Construction_Package_ID__c = :conID AND (Status__c = 'Rejected' OR Status__c = 'Not Resolved')];
        return  rejlst ;
    }
}

 

Best Answer chosen by Admin (Salesforce Developers) 
ManoharSFManoharSF

Fixed. the 'MAC' in the ID string was throwing off. Not sure where its coming from.

 

After having below, it worked.

 

conID = conID.replace('MAC','');

 

 

Thanks for all the suggestions.

All Answers

sandeep@Salesforcesandeep@Salesforce

Please remove with sharing key word from your class and check it again.

Puja_mfsiPuja_mfsi

Hi,

  • Have you pass relatedTo id when you check the mail template.

In Email template there is a button "Send Test and Verify Merge Fields"  ,when you click on that button a popup is open and there r two mandatory fields,One -Recipient Record   Second - Related To Record. Select "Construction_Package__c" record in related to Record  and 'Contact' record in Recipient Record.

and click on 'OK' then you can see your result in 'HTML preview'

 

  • If you already check the first way,then please check your query in developer console,whether it gives any value or not( put any hardcoded id in place of 'conID'.

 

Please let me know if u have any problem on same and if this post helps u plz give KUDOS by click on star at left.

 

ManoharSFManoharSF
@Sandeep, it dint work.

@Puja, preview still dint give me any records. Also made sure soql is valid and is pulling the right record.

One thing I noticed is related to I'd is concatenated with 'MAC', is that. Normal?

Thanks for checking.
Manohar
Puja_mfsiPuja_mfsi

Hi,

Please check in the following block ( our block )

http://mindfiresfdcprofessionals.wordpress.com/

 

I have write down a post regarding same with Title

Send mail with attachment using Visual force Email Template and visual force Component

please cross check uor code with this post.

 

 

Please let me know if u have any problem on same and if this post helps u plz give KUDOS by click on star at left.

ManoharSFManoharSF

Fixed. the 'MAC' in the ID string was throwing off. Not sure where its coming from.

 

After having below, it worked.

 

conID = conID.replace('MAC','');

 

 

Thanks for all the suggestions.

This was selected as the best answer