0

I have create a VF page for (PDF) quote generation however i'm struggling keeping the currency symbol and amount together.

enter image description here

Looking at my code ...

{!$Label.Quote_PDF_AgreesOnPlanned_Act}
    <b>
    {!
      IF(Opportunity.CurrencyIsoCode = "USD","$ ", 
      IF(Opportunity.CurrencyIsoCode = "EUR","€ ", 
      IF(Opportunity.CurrencyIsoCode = "JPY","¥ ", 
      IF(Opportunity.CurrencyIsoCode = "GBP","£ ", 
      IF(Opportunity.CurrencyIsoCode = 'DKK','DK', 
      IF(Opportunity.CurrencyIsoCode = 'CHF','Sf',              
         Opportunity.CurrencyIsoCode)
    )))))
    }
    </b>
    <b> 
    <!-- Hide when subscription = true -->
    <apex:outputText escape="false" value="{0, number, ###,###,###,##0.00}" rendered="{!!showSubscriptionsTable}">
       <apex:param value="{!Opportunity.Amount}" ></apex:param>
    </apex:outputText>
    </b>
1
  • Try solving it with the HTML tag &nbsp; – Sander de Jong Oct 23 '18 at 14:56
1

Change this code:

    </b>
    <b> 

To this code:

    </b>&nbsp;<b> 

You need to make sure that there's no white space, or HTML will be allowed to break there. In fact, you could really just take out that bit of code:

{!$Label.Quote_PDF_AgreesOnPlanned_Act}
    <b>
    {!
      IF(Opportunity.CurrencyIsoCode = "USD","$ ", 
      IF(Opportunity.CurrencyIsoCode = "EUR","€ ", 
      IF(Opportunity.CurrencyIsoCode = "JPY","¥ ", 
      IF(Opportunity.CurrencyIsoCode = "GBP","£ ", 
      IF(Opportunity.CurrencyIsoCode = 'DKK','DK', 
      IF(Opportunity.CurrencyIsoCode = 'CHF','Sf',

         Opportunity.CurrencyIsoCode)
    )))))
    }<!-- Hide when subscription = true 
    --><apex:outputText escape="false" value="{0, number, ###,###,###,##0.00}" rendered="{!!showSubscriptionsTable}">
       <apex:param value="{!Opportunity.Amount}" ></apex:param>
    </apex:outputText>
    </b>

It's all about white-space management.

3
  • It also depends somewhat on the customer's requirements for how "pretty" they want it to look. Not everyone will find the lack of the non-breaking space appealing, but I agree he could remove all of the If statements. +1 – crmprogdev Oct 23 '18 at 21:22
  • Stipped the code back to this .. and no luck ... i'm not even sure if this would be duable using Case control. It's a pitty sfdc lack support of string method with parameters from VF. Then I could solve it with an simple method .. (function). – Jos Vervoorn Oct 24 '18 at 20:52
  • {!$Label.Quote_PDF_AgreesOnPlanned_Act} <b> {! IF(Opportunity.CurrencyIsoCode = 'US','$', IF(Opportunity.CurrencyIsoCode = 'EUR','€', IF(Opportunity.CurrencyIsoCode = 'CHF','Sf',Opportunity.CurrencyIsoCode) )) } <apex:outputText escape="false" value="{0, number, ###,###,###,##0.00}" rendered="{!!showSubscriptionsTable}"> <apex:param value="{!Opportunity.Amount}"></apex:param> </apex:outputText> – Jos Vervoorn Oct 24 '18 at 20:53
1

You need to slightly modify your code to add a non breaking space code like below to all of your equivalent lines:

IF(Opportunity.CurrencyIsoCode = "USD","$&nbsp;", 

Doing that should cause the currency symbol to stay with the value and not allow the break to occur.

3
  • 1
    other enhancements would include using a CASE formula and moving the currency symbol logic into a reusable VF custom component – cropredy Oct 23 '18 at 18:10
  • That did not help I'm afraid ... now the line says ..Hereby Mr Stein agrees on the scope and planned activities for the amount of €&nsp; 169,100.00 (based on actual costs excl. VAT). – Jos Vervoorn Oct 24 '18 at 20:50
  • I made a typo. That should be &nbsp;. My apologies. Will fix it in my answer too. – crmprogdev Oct 25 '18 at 0:16
-1

Seems devil was in the details. "white-space management" triggered me to look closer .... removing the blanks here value="{0, number, ###,###,###,##0.00}" worked magic ...

1
  • What blanks are you referring to? This looks the same as the code you posted. – Matt Lacey Oct 25 '18 at 0:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.