We have a problem in my org related to the locale and the creation of the Quote PDF.

We have 2 offices ("Europe" and "America") for the Quote object, specified in the Office (Office__c) picklist field.

We have an ETL using REST API that at some point modifies the Quote and this triggers a Flow that creates a standar PDF calling an Apex class.

The problem we have is that the PDF is always created with the locale of the API User, which is: "Spanish (Spain)".

We need that the Quote PDF is created with the locale related to the Office: · If Europe -> Spanish (Spain) · If America -> English (United States)

How can we achive that?


This is how I am generating the Quote PDF via apex:

Public class generateQuotePdfDocument{

public static void quotesIdToPDF(List<Id> quoteIds)  

    if(!quoteIds.isEmpty() && quoteIds.size() > 0) {
        for(Id quoteId :quoteIds) {

public static void insertQuoteTemplate(String quoteId) {

    //Get the Quote Template Id from Custom Settings
    String quoteTemplateId = Label.QuoteTemplateId;
    Quote q = [SELECT Id FROM Quote WHERE Id = :quoteId];
    //Construct de Quote URL to generate PDF   
    String quoteUrl = '/quote/quoteTemplateDataViewer.apexp?id='+quoteId+'&headerHeight=19&footerHeight=10&summlid='+quoteTemplateId;
    //call the quote url
    PageReference pageRef = new PageReference(quoteUrl);
    //get the quotePdf
    Blob quoteBlob;
    if(Test.isRunningTest()) {
        quoteBlob = Blob.valueOf('Generate Pdf');
    } else {
        quoteBlob = pageRef.getContentAsPDF();
    //Initialze the QuoteDocument to hold the quote pdf for insertion
    QuoteDocument quoteDoc = new QuoteDocument();
    quoteDoc.Document = quoteBlob;
    quoteDoc.QuoteId = quoteId;
    //List variable to get all the Quote Documents
    List<QuoteDocument> lstQuoteDoc = new List<QuoteDocument>();
    if(!lstQuoteDoc.isEmpty() && lstQuoteDoc.size() > 0) {

Note: The languange of the PDF doesn't matter. The important thing is we need to change the locale to show correctly Currencies delimiters, based on the Quote Office custom picklist field and using the same User.


  • how are your Quote Templates organized by language? Is this OOTB Quotes or CPQ. Or is the quote template something custom (a VF page). More detail is required
    – cropredy
    Mar 31, 2022 at 1:19
  • Thanks for comment @cropredy, we have only 1 template Id. We don't use VF page. Mar 31, 2022 at 11:45


Your Answer

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

Browse other questions tagged or ask your own question.