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
Rai SahitaRai Sahita 

Naming the pdf file controller is fine in Sandbox but not working in production

Hello, Good afternoon.

anyone cound help me please. My code is below

public class Tsuchisho_Name {
    public Lead ld {get; set;}
    
     public Tsuchisho_Name(ApexPages.StandardController stdController){
        ld = new Lead();
        ld = (Lead)stdController.getRecord();
        
        ld = [SELECT Id, Name FROM Lead LIMIT 1];
        
        String pdfName = ld.Name + '.pdf';
        Apexpages.currentPage().getHeaders().put( 'content-disposition', 'inline; filename=' + pdfName);
        
    }

}
 

and TestClass is 
 

@isTest
public class TsuchishoNameTest {
    @isTest
    static void Tsuchisho_Name(){
        
        Lead l = new Lead();
        l.FirstName = 'leadname';
        l.LastName = 'lastName';
        l.AnnualIncomePresentationAmount__c = 1000;
        l.DateOfAcceptance__c = system.today();
        l.Notice_Date__c = system.today();
        l.Company = 'next';
        
        insert l;
        
        ApexPages.StandardController stdController = new ApexPages.StandardController(new Lead());
        Tsuchisho_Name tsuchi = new Tsuchisho_Name(stdController);
        
        Test.startTest();
        
        tsuchi.ld = l;   
        Lead led = tsuchi.ld;
        String Name = led.Name;
        
        Test.stopTest();
    }

}

With regards Rai

Thank you

PriyaPriya (Salesforce Developers) 
Hey Rai,

What is the error and at which line?

Thanks!
Rai SahitaRai Sahita

Using above controller  I can set a dynamic filename of PDF(Visualforce page). but only Japanese characters are not shown

   e.g. when PDF file name is 'あああ'  

Geoffrey HillsGeoffrey Hills
I didn't grant the user clicking the button security access to the VF page and controller. Usually you get a insufficient privileges error displayed on the page but since there isn't really a page ever displayed you don't get this warning.
Myhdfs Account Login (https://www.myhdfs.net/)