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
Chris S. 5Chris S. 5 

Generate PDF Button

Hello,
We had a working "Generate PDF" button for some of our cases. The button has stopped working properly. I checked the Apex for the visualforce page, but when trying to preview, I get the following message "List has no rows for assignment to SObject." I know I'm missing something, but I can't seem to find it. Any help is greatly appreciated. This is the current code:
 
<apex:page standardController="Case" extensions="DmcaCaseExt" renderAs="pdf" language="{!languageCode}">
  <apex:pageBlock >
      <apex:pageBlockSection >
      <h2>Digital Millenium Copyright Act Notice Form</h2>
      </apex:pageBlockSection>
      
      <apex:pageBlockSection >
        <p>The Digital Millennium Copyright Act (”DMCA”) is a United States copyright law that provides guidelines for online service providers in case of copyright infringement. Below is the information that should be present in these notices. It is designed to make submitting notices of alleged infringement to us as straightforward as possible while reducing the number of notices that we receive that are fraudulent or difficult to understand or verify. The form of notice specified below is consistent with the DMCA, which can be found at the U.S. Copyright Office website, http://www.copyright.gov.</p>
        <p>To file a notice of infringement with us, you must provide us with the items specified below. Please note that you will be liable for damages (including costs and attorneys' fees) if you materially misrepresent that the material is infringing your copyright. Accordingly, if you are not sure whether material infringes your copyright, we suggest that you first contact an attorney.</p>
        <p>This notice and any attachments we receive will be forwarded to the alleged infringer, who will then have the opportunity to file a counter notification pursuant to Sections 512(g)(2) and (3) of the DMCA. Should a properly filed counter notifica- tion be filed, you will be notified and have 10 business days within which to file for a restraining order in Federal Court to prevent the reinstatement of the material.</p>
        <p>* Denotes a required field. All required fields must be filled out for us to be able to process your form.</p>
      </apex:pageBlockSection>
      
      
      
      
      <!--text omitted from PDF<h2>Complainant's Information:</h2>-->
      First Name: <apex:outputField value="{!dmcaCase.First_Name__c}" /><br/>
      Last Name: <apex:outputField value="{!dmcaCase.Last_Name__c}" /><br/>
      Title: <apex:outputField value="{!dmcaCase.DMCA_Complainant_Title__c}" /><br/>
      Company: <apex:outputField value="{!dmcaCase.SuppliedCompany}" /><br/>
      Address: <apex:outputField value="{!dmcaCase.QC_Complainant_Address__c}"/><br/>
      Country: <apex:outputField value="{!dmcaCase.QC_Complainant_Country__c}"/><br/>
      Email: <apex:outputField value="{!dmcaCase.SuppliedEmail}"/><br/>
      Phone Number: <apex:outputField value="{!dmcaCase.SuppliedPhone}"/><br/>
      
      <h2>Your Copyrighted Work:</h2>
      <p>
      Identify in sufficient detail the copyrighted work that you believe has been infringed upon (for example, "The copy- righted work at issue is the image that appears on http://www.lulu.com/####") or other information sufficient to specify the copyrighted work being infringed. You may attach supporting documentation.
      </p>
      <div style="border-bottom: 1px solid;"><apex:outputField value="{!dmcaCase.DMCA_Description__c}"/></div>
      
      <br/>
      
      <h2>Location of Infringing Material:</h2>
      <p>Identify each web page that allegedly contains infringing material. This requires you to provide the URL for each allegedly infringing result, document or item.</p>
      <div style="border-bottom: 1px solid;"><apex:outputField value="{!dmcaCase.Problem_URL__c}"/></div>
      
      <br/>
      
      <h2>Sworn Statements:</h2>
      <p>I have a good faith belief that use of the copyrighted materials described above as allegedly infringing is not authorized by the copyright owner, its agent, or the law.</p>
      <apex:outputField value="{!dmcaCase.DMCA_Sworn_Confirm__c}"/> Please check to confirm*
      
      <br/>
      
      <p>I swear, under penalty of perjury, that the information in the notification is accurate and that I am the copyright owner or
am authorized to act on behalf of the owner of an exclusive right that is allegedly infringed.</p>
        <apex:outputField value="{!dmcaCase.DMCA_Accurate_Confirm__c}"/> Please check to confirm* 
      
      <br/>
      
      <h2>Signature:</h2>
      <!--text omitted from PDF<p>Signature:* (Your digital signature is as legally binding as a physical signature. If you use a digital signature, your signa- ture must exactly match the First and Last names that you specified earlier in this form):</p>-->
      
      <!-- signature and date here -->
      Signed: <div style="border-bottom: 1px solid;"><apex:outputField value="{!dmcaCase.DMCA_Signature__c}"/></div>
      <br/>
      Date: <div style="border-bottom: 1px solid;"><apex:outputField value="{!dmcaCase.DMCA_Signed_Date__c}"/></div>
     
      <p>This form does not constitute legal advice and nothing that you read or are provided on this web site should be used as a substitute for the advice of competent legal counsel.</p>
      
      
  </apex:pageBlock>
  
 
</apex:page>

 
Nagarjuna Reddy NandireddyNagarjuna Reddy Nandireddy
Hello,
Please create a Visualforce Custom button in Case Layout. Than click that custom button you will get an output......!

Regards,
Nagarjuna Reddy Nandireddy
Mustafa JhabuawalaMustafa Jhabuawala
Chris,

It seems you have a apex controller named as DmcaCaseExt, there is some issue in the apex class itself. Can you share that code ?

This error occurs when your SOQL query doesn't returns any row.

For ex - 
ObjectSample__c sample = [SELECT Id from ObjectSample__c where Some := Value];

To be on safer side you should write this to avoid the exception - 
ObjectSample__c[] samples = [SELECT Id from ObjectSample__c where Some := Value];

Refer this link (https://help.salesforce.com/articleView?id=000159853&language=en_US&type=1)for more details on this error.
Sukanya BanekarSukanya Banekar
Hi,
You are getting this error because the query which you have written can not return anything from the object.
You can put the query in try catch block so that you will not receive the error.
Case c= new Case();
    try{
        c= [SELECT id from Case limit 1];
    }
   catch(Exception e){
       c= new Case();
        system.debug('------'+c.Status); // will return null 
    }

Hope this will help you.

Thanks,
Sukanya Banekar
 
JeremyMSJeremyMS
I am Chris S's colleague. Here is the Apex Class DmcaCaseExt:
public class DmcaCaseExt {
    
    public Case dmcaCase {get; private set;}
    public String languageCode {get; private set;}
    
    public DmcaCaseExt(ApexPages.StandardController controller) {
        Id caseId = ((Case)controller.getRecord()).Id;
        dmcaCase = [select Id, First_Name__c, Last_Name__c, SuppliedEmail, SuppliedPhone, Language__c, DMCA_Complainant_Title__c, QC_Complainant_Address__c, QC_Complainant_Country__c, SuppliedCompany,
                    DMCA_Description__c, DMCA_Sworn_Confirm__c, DMCA_Accurate_Confirm__c,  DMCA_Signed_Date__c, DMCA_Signature__c, Problem_URL__c from Case where Id = :caseId];
    
    }
   
    
    public PageReference setLocale(){
    
        
        if(dmcaCase.Language__c == 'German'){
            languageCode = 'de';
            return Page.DmcaPDF_DE;
        } else if(dmcaCase.Language__c == 'French'){
            languageCode = 'fr';
            return Page.DmcaPDF_FR;
        } else if(dmcaCase.Language__c == 'Spanish'){
            languageCode = 'es';
            return Page.DmcaPDF_SP;
        } else if(dmcaCase.Language__c == 'Italian'){
            languageCode = 'it';
            return Page.DmcaPDF_IT;
        } else if(dmcaCase.Language__c == 'Dutch'){
            languageCode = 'nl';
            return Page.DmcaPDF_NL;
        } else {
            languageCode = 'en';
            return Page.DmcaPdf_EN;
        }
        
    }

}
And the custom 'Generate PDF' button on our Case layout 'opens in existing window without sidebar' with a 'URL' content source and redirects here:
/apex/DmcaPdf?id={!Case.Id}
It looks like the problem is coming from the dmcaCase variable assignment, but we're not sure how to implement the suggested solutions. We haven't changed this code in years, and this problem started happening on July 28. Any tips? Thanks much!