【问题标题】:Bold Text in Email Template based on IF condition in Salesforce基于 Salesforce 中 IF 条件的电子邮件模板中的粗体文本
【发布时间】:2020-07-01 16:51:12
【问题描述】:

我需要根据 Salesforce Visualforce 电子邮件模板中的 IF 语句将文本加粗。有人可以帮我吗。在下面的顶点 html 标记中,当 If Condition 为 True 时,我需要将 Required 文本加粗。

<apex:outputText value="{!IF(AND(NOT(ISBLANK(relatedTo.Quote__r.Margin__c)),NOT(ISBLANK(relatedTo.Quote__r.Threshold__c)),relatedTo.Quote__r.Margin__c<relatedTo.Quote__r.Threshold__c), 
                            "Required", "Not Required" )}" />

【问题讨论】:

    标签: html salesforce apex visualforce email-templates


    【解决方案1】:

    这看起来有点讨厌(重复的标签),但应该很可靠。您可以将条件直接放在 rendered 属性中,但如果您需要更改它,您可能会忘记并只在 1 个地方执行,那将是“有趣”的错误。

    <apex:variable var="condition" value="{!AND(NOT(ISBLANK(relatedTo.Quote__r.Margin__c)),NOT(ISBLANK(relatedTo.Quote__r.Threshold__c)),relatedTo.Quote__r.Margin__c<relatedTo.Quote__r.Threshold__c)}" />
    
    <apex:outputPanel layout="inline" rendered="{!condition}">
        <b>Required</b>
    </apex:outputPanel>
    <apex:outputPanel layout="inline" rendered="{!!condition}">
        Not Required<!-- you could also put it in `value`-->
    </apex:outputPanel>
    

    如果你不想重复代码,你可以尝试类似

    <apex:variable var="condition" value="{!AND(NOT(ISBLANK(relatedTo.Quote__r.Margin__c)),NOT(ISBLANK(relatedTo.Quote__r.Threshold__c)),relatedTo.Quote__r.Margin__c<relatedTo.Quote__r.Threshold__c)}" />
    
    <apex:outputText value="{!IF(condition, 'Required', 'Not Required')}" style="{!IF(condition, 'font-weight:bold, '')}" />
    

    您应该测试第二个版本,如果电子邮件客户端决定忽略样式怎么办。虽然像这样的内联样式应该没问题,但 &lt;style&gt; 标签中的“仅”CSS 往往不可靠......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多