1

As a test, I included "This is classic" which prints. Why doesn't apex:pageMessages run?

As another test, I included "This is script" which alerts correctly. Why doesn't sendEmailFromVF run?

<apex:page standardController="zqu__Quote__c" extensions="SendEmailWithTemplateController">
    <apex:form >
        <apex:outputPanel id="classicPanel" rendered="{! $User.UIThemeDisplayed == 'Theme3'}">
            This is classic
            <apex:pageMessages escape="false"/>
            <script>
                alert("This is script");
                sendEmailFromVF();
            </script>
        </apex:outputPanel>
        <apex:actionFunction name="sendEmailFromVF" action="{!sendEmail}" rerender="classicPanel"/>
    </apex:form>
</apex:page>

Here's part of the controller, showing that we do send messaging to the view via pageMessages

public PageReference sendEmail() {
    Boolean success = true;
    System.debug('Sending email ' + currentQuote);
    try {
        // if none of the Contact email fields: Email, Email_From_Admin__c and Archived_Email_Opt_Out__c are populated, we throw an error
        if (String.isEmpty(currentQuote.zqu__BillToContact__r.Email)
            && String.isEmpty(currentQuote.zqu__BillToContact__r.Email_From_Admin__c)
            && String.isEmpty(currentQuote.zqu__BillToContact__r.Archived_Email_Opt_Out__c))
        {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'The "Bill to Contact" associated with the quote has an empty email'));
            return null;
        } else if (currentQuote.zqu__Previewed_MRR__c == null) {
            success = false;
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'The e-mail template is still being generated. Please retry the "Email Quote" button in a moment. ' + JAVASCRIPT_HISTORY_BACK_LINK));
            return null;

All was working fine before I started trying to specify this is only if the User is coming from Classic with $User.UIThemeDisplayed

This code works perfectly:

<apex:page standardController="zqu__Quote__c" extensions="SendEmailWithTemplateController" action="{!sendEmail}">
<apex:pageMessages escape="false"/></apex:page>
0

1 Answer 1

0

Remove the conditional rendering ($User.UIThemeDisplayed) from the outputPanel that will be reRendered and instead add it to a sub tag. Then your conditional rendering will behave accordingly and the actionFunction will begin to work again.

 <apex:outputPanel id="classicPanel" >
     <apex:someOtherTag rendered="{! $User.UIThemeDisplayed == 'Theme3'}">
        This is classic
        <apex:pageMessages escape="false"/>
        <script>
            alert("This is script");
            sendEmailFromVF();
        </script>
        </apex:someOtherTag>
    </apex:outputPanel>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .