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
Tabrez Ansari 14Tabrez Ansari 14 

Error Message: core.email.template.TemplateRenderingException: java.lang.IllegalStateException: You cannot ask for this if the context hasn't been established

once my record is submitted for approval, I enqueue time-dependent actions, send email alert & create a Task.
I'm using Process Builder to do the above.
My Template as Follows
<messaging:emailTemplate recipientType="Contact" relatedToType="Demo_Equipment_Request__c" subject="REMINDER...!! Demo Equipment Request {!relatedTo.Name} Pending Approval">
    <messaging:htmlEmailBody >        
        <html>
            <body>
                <STYLE type="text/css">
                    P {font-size: 16px; font-family: arial; max-width:650px }
                    DIV {font-size: 14px; font-family:arial; max-width:650px}
                    TH {font-size: 16px; font-family: arial;background: #CCCCCC; border-width: 1;  text-align: center; width: 120px } 
                    TD  {font-size: 14px; font-family: verdana } 
                    TABLE {border: solid #CCCCCC; border-width: 0}
                    TR {border: solid #CCCCCC; border-width: 0}
                </STYLE>

                <div style="text-align:right" ><apex:image value="https://c.na16.content.force.com/servlet/servlet.ImageServer?id=015f1000002vlRm&oid=00Dj0000001tVXM" height="50"/></div>
                
                <p>Dear Approver</p>
                <p>Your approval is pending for the following request.<br/>
                Kindly approve.</p>
                
                <p>Demo Request : &nbsp; <apex:outputlink value="{!LEFT($Api.Partner_Server_URL_140,FIND('.com',$Api.Partner_Server_URL_140)+4)+relatedTo.Id}">{!relatedTo.Name}</apex:outputlink></p>
                
                <p><c:Email_Signature /></p>

                <p>Product(s) requested:</p>

                <table border="0" >
                    <tr>
                        <th width="30%">Product</th>
                        <th width="30%">Product Description</th>
                    </tr>                 
                    <apex:repeat var="prod" value="{!relatedTo.Demo_Products__r}">
                        <tr>
                            <td>{!prod.Display_Product__c}</td>
                            <!--<td>{!prod.Product__r.Description}</td>-->
                        </tr>
                    </apex:repeat>
                </table>
            </body>
        </html>
    </messaging:htmlEmailBody> 
</messaging:emailTemplate>
I get the following Error on execution.
47.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
21:32:59.0 (519336)|USER_INFO|[EXTERNAL]|0056g000000FK1u|tabreza@cybage.com|(GMT-08:00) Pacific Standard Time (America/Los_Angeles)|GMT-08:00
21:32:59.0 (301773462)|FLOW_ELEMENT_ERROR|We were unable to process the email template.
 Error Message: core.email.template.TemplateRenderingException: java.lang.IllegalStateException: You cannot ask for this if the context hasn't been established
|FlowActionCall|myWaitEvent_myWait_myRule_12_event_0_SA1
21:32:59.951 (951419199)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:BatchApexErrorEvent
21:32:59.951 (968867599)|CODE_UNIT_FINISHED|EventService:BatchApexErrorEvent
21:32:59.970 (970576275)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:FlowExecutionErrorEvent
21:32:59.970 (975281800)|CODE_UNIT_FINISHED|EventService:FlowExecutionErrorEvent
21:32:59.976 (976826046)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:PlatformStatusAlertEvent
21:32:59.976 (980991812)|CODE_UNIT_FINISHED|EventService:PlatformStatusAlertEvent
21:33:00.27 (1027519590)|USER_INFO|[EXTERNAL]|0056g000000FK1u|tabreza@cybage.com|(GMT-08:00) Pacific Standard Time (America/Los_Angeles)|GMT-08:00
21:33:00.27 (1027542613)|EXECUTION_STARTED
21:33:00.27 (1027549036)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:BatchApexErrorEvent
21:33:00.27 (1031813321)|CODE_UNIT_FINISHED|EventService:BatchApexErrorEvent
21:33:00.27 (1033024784)|EXECUTION_FINISHED
21:33:00.34 (1034705907)|USER_INFO|[EXTERNAL]|0056g000000FK1u|tabreza@cybage.com|(GMT-08:00) Pacific Standard Time (America/Los_Angeles)|GMT-08:00
21:33:00.34 (1034728397)|EXECUTION_STARTED
21:33:00.34 (1034734081)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:FlowExecutionErrorEvent
21:33:00.34 (1038553061)|CODE_UNIT_FINISHED|EventService:FlowExecutionErrorEvent
21:33:00.34 (1039751379)|EXECUTION_FINISHED
21:33:00.41 (1041362712)|USER_INFO|[EXTERNAL]|0056g000000FK1u|tabreza@cybage.com|(GMT-08:00) Pacific Standard Time (America/Los_Angeles)|GMT-08:00
21:33:00.41 (1041381874)|EXECUTION_STARTED
21:33:00.41 (1041386902)|CODE_UNIT_STARTED|[EXTERNAL]|EventService:PlatformStatusAlertEvent
21:33:00.41 (1045299052)|CODE_UNIT_FINISHED|EventService:PlatformStatusAlertEvent
21:33:00.41 (1046804143)|EXECUTION_FINISHED
Please Assist.