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
sfdcfoxsfdcfox 

[Regression/Bug?] PDF: SObject row was retrieved ... requested field: Quote.ShippingName

We have two pages, aptly named QuotePDF and QuotePDF1. The former is designed to allow the user to preview the quote and save it to the quote and optionally send an email with it attached. Yes, we know this is standard functionality, but we're doing "extra" stuff with our code that we wanted to retain.

 

At any rate, with no changes to our code, we suddenly had a break in our code. Previously, it was working great without a problem. Now, the Preview works as expected, but Page.QuotePDF1.getContent() is failing with the error "SObject row was retrieved via SOQL without querying the requested field: Quote.ShippingName", regardless of what we try to do to fix the problem. Here's what we've got in place so far:

 

public with sharing class quotePDFExtension {
    public quotePDFExtension(Apexpages.standardcontroller con) {
        controller = con;
        if(!test.isrunningtest()) {
            con.reset();
// Cached field describe as a String[] con.addfields(data_util.getobjectfields('Quote')); } } // Other non-interesting stuff here, including controller variable public apexpages.pagereference saveToQuote() { quotedocument qd = new quotedocument(); apexpages.pagereference ref = page.quotepdf1; ref.getparameters().put('id',quote.id); qd.document = ref.getcontent(); // also tried getcontentaspdf
// ref.setredirect(true/false); -- neither had any effect qd.quoteid = quote.id; insert qd; return controller.view(); } }

The controller explicitly has all fields added to it, we've tried to force a redirect.

 

Yes, both pages use the same standardController(Quote) and extensions(quotePDFExtension). I'd rather not split them apart if I can help it.

 

Up until this previous weekend, everything was running just fine. However, whatever happened this weekend broke several pieces of code that was previously working. I can't seem to debug this either, as the error causes the entire page to crash rather ungracefully.

 

I've tried several fixes that mentioned this problem from 2009, but to no avail, including static variables, etc. The only thing I don't want to do is hardcode a query in place, as this is rather limiting. I'd like to have the system determine what fields should be queried dynamically, the way it should be.

DahveedDahveed

I realize this was forever ago but I'm seeing the same issue. I was wondering, did you ever find the answer to this or did you wind up putting a SOQL query in?

 

Thanks

 

Dahveed

sfdcfoxsfdcfox

The "solution" was to add all of the fields to the page in an apex:outputText area (rendered="false") on QuotePDF so that all the fields we wanted were queried. This was non-ideal, but we never found a viable workaround. The alternative (which we'll be implementing soon) is to two different controllers so as to force the system to not share view state. This was even after a round with technical support, which recommended the former action and refused to investigate why the page would suddenly stop working correctly.

DahveedDahveed
Thanks heaps for the response. I just separated the controllers and it
worked great. I was beating my fist not understanding why it wasn't
working. I guess it's an Apex transaction thing.