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
etessetess 

No protocol error?

I have a VF Page that is displaying an inline frame of a PDF which I'd like to use as a "Preview PDF" page. I am trying to create a button that executes an APEX method to save the PDF as a QuoteDocument and redirect to Quote Detail page. However, I am getting the following error:

 

no protocol: Page.bidPDF?id=0Q0P00000008Pk5KAE&inline=1

 

I am stumped - any insights would be much appreciated

 

My VF page:

 

<apex:page standardController="Quote" title="PDF Preview" extensions="quoteExtension">
<apex:sectionHeader title="Quote (PDF Preview)" subtitle="{!quote.Name}"/>

<p><a href="../{!quote.id}"><font style="font-size: 11px">« Back to Quote</font></a></p>

<apex:pageBlock>
Below is a preview of your PDF. If your browser does not support PDF preview, it will ask you to download the PDF.
</apex:pageBlock>

<p>
<apex:form>
<apex:commandButton value="Save" action="{!quotePDFSave}"/>
</apex:form>
</p>
<apex:iframe src="apex/bidPDF?id={!quote.id}" width="80%"/>

</apex:page>

 

 

 

My APEX Class:

 

public class quoteExtension {

private final Quote qte;

public quoteExtension(ApexPages.StandardController stdController) {
this.qte = (Quote)stdController.getRecord();
}

public PageReference quotePDFSave(){

// Get PDF Template and Create Blob
PageReference QuotePDFPage = new PageReference('Page.bidPDF?id='+qte.Id);
Blob QuotePDFBlob = QuotePDFPage.getContentAsPDF();

//Attach
QuoteDocument qd = new QuoteDocument(quoteid = qte.id, discount = qte.Discount, grandtotal=qte.TotalCost__c, document=QuotePDFBlob);
insert qd;

//Redirect
PageReference detailPage = new PageReference('../'+ qte.id);
detailPage.setRedirect(true);
return detailPage;

}

}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
forecast_is_cloudyforecast_is_cloudy

Small typo with the VF page name. Try

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id); 

All Answers

jeremyyjeremyy

I'm guessing this is the culprit:

 

 

PageReference detailPage = new PageReference('../'+ qte.id);

 

I'm not sure PageReference can deal with that type of relative URL. If not, it may be building an absolute URL explicitly based on what you're passing in the constructor, which doesn't have a protocol (http, http, ftp, etc.) and wouldn't work even if it did. Try getting rid of the parent directory notation.

 

etessetess

Hm, that might be a different issue, but the error message seems to be referring to the following code & not that last redirect line:

PageReference QuotePDFPage = new PageReference('Page.bidPDF?id='+qte.Id);
etessetess

Actually, I realize in error message, "KAE&inline=1" is getting appended from somewhere but should not be - i've highlighted the correct Quote ID in blue from when I test it

 

Error: no protocol: apex/bidPDF?id=0Q0P00000008Pk5KAE&inline=1

forecast_is_cloudyforecast_is_cloudy

Try

 PageReference QuotePDFPage = new PageReference('/apex/idPDF?id='+qte.Id); 
forecast_is_cloudyforecast_is_cloudy

Small typo with the VF page name. Try

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id); 
This was selected as the best answer
etessetess

Thanks! It was the difference between:

 

PageReference QuotePDFPage = new PageReference('apex/bidPDF?id='+qte.Id); 

and

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id);