• Matt1000
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies

On the SF Quote Page, I see that I can override Create PDF to show my own VIsualForce page. I can also "RenderAs" a PDF. This works as expected.

 

But how can I show my own VisualForce page in the pdfOverlay that is shown when the user clicks "Create PDF" when there is no override. In this case, a standard template is served up on the "pdfOverlay" window, with default buttons (Save to Quote, Save and Email Quote, and Cancel).

 

I want my Visualforce quote document to appear in that window, using those same buttons.

 

Basically, I want to use my own template via a VIsualforce page, rather than the more restrictive Templates available to us via the standard quote templates. The template layout options just don't seem to permit the coplexity I need. For example, it is not possible (I think) to create multi-page Terms & Conditions, and lengthy paragraph language to develop a longer form quotation to the customer.

 

Is there a simple way to reuse that PDF overlay with my own VIsualForce PDF, including the existing "Save to Quote" (etc.) buttons in the PDF Overlay ?

 

This would save me lots of time.

 

P.S. The SF Quote page's HTML source shows the following, which is why I thought pdfOverlay had some relevance:

 

HTML Snippet From SF Quote Page:

 

 

<input value="Create PDF"  class="btn" title="Create PDF" name="createpdf" onclick="null
 var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay'];pdfOverlay.dialog.buttonContents = '&lt;input value=\&quot;Save to Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;save\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');\&quot; title=\&quot;Save to Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Save and Email Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;saveAndEmail\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');\&quot; title=\&quot;Save and Email Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Cancel\&quot;  class=\&quot;btn\&quot; name=\&quot;cancel\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();\&quot; title=\&quot;Cancel\&quot; type=\&quot;button\&quot; /&gt;';
pdfOverlay.summlid = '0EHE0000000PCKI';
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id=0Q0E0000000TNLo','/quote/quoteTemplateHeaderData.apexp?id=0Q0E0000000TNLo');
pdfOverlay.display();
" type="button" />

Any advice to get to this solution? 

 

Thanks, Matt

 

The following code is supposed to delete all products from the current Opportunity:

 

delete [ Select Id from OpportunityLineItem WHERE OpportunityID = :ApexPages.currentPage().getParameters().get('id') ];

 

...but it results in this error:

 

"DML currently not allowed"

 

The email generated to me from Salesforce about the error says:

System.LimitException: DML currently not allowed

 

Note: I am using Developer Edition.

 

Can anyone explain why this code is failing?

 

Thanks!

I have a class that inserts an OpportunityLineItem into an Opportunity.

The following statement is permitted:
    opportunitylineitem.PriceBookEntryID = '01uE0000000KoyD'; // literal is permitted
But the following statement results in an "Attempt to de-reference a null object" error
    opportunitylineitem.PriceBookEntryID = entry[0].id; // where entry is a LIST<PriceBookEntry> element
Investigating the PriceBookEntry table, I see that the PriceBookEntry ids are 18 characters long, where the literal permitted (and used on the usual Add Products to Opportunity page) is only 15 characters. I tried truncating the id via String.valueOf(entry[0].id).substring(0,15) but this causes the same de-reference error.
Is there a way to assign the id directly, or truncate it down to the needed 15 characters, without the dereference error? If I could get this, I'd be able to develop our solution further.
(Or am I missing something, a better approach.)
Here is the class. See the red highlighted lines.
//////////////////////
public class addProductToOp003 {
  Opportunity opportunity;
  
  public Opportunity getOpportunity() {
        opportunity = [SELECT id, name, PriceBook2Id FROM Opportunity
                WHERE id = :ApexPages.currentPage().getParameters().get('id')];
        return opportunity;
    }
    
    PriceBook2 pricebook2;
    public PriceBook2 getPriceBook2() {    
        pricebook2 = [SELECT id, name FROM PriceBook2 WHERE id=:opportunity.PriceBook2Id LIMIT 1];
        return pricebook2;
    }
    LIST<PriceBookEntry> entry;
    
    public LIST<PriceBookEntry> getEntry() {
        entry = [Select Id, name from PriceBookEntry where pricebook2id = :opportunity.PriceBook2Id ];
        return entry;
    }
    
    OpportunityLineItem opportunitylineitem;
    
    public OpportunityLineItem getOpportunityLineItem() {
        if(opportunitylineitem == null) opportunitylineitem = new OpportunityLineItem();
        opportunitylineitem.OpportunityID = ApexPages.currentPage().getParameters().get('id');
        //01uE0000000d3Y8 is PriceBookEntryID from HTML <form> on Add Products to Opportunity page
        //01uE0000000KoyD is a truncated ID from a different product in the PriceBookEntry table
        opportunitylineitem.PriceBookEntryID = '01uE0000000KoyD'; //'01uE0000000d3Y8'; // works as literal like this
        // opportunitylineitem.PriceBookEntryID = entry[0].id; // fails with de-reference error on visual force page
        // opportunitylineitem.PriceBookEntryID = String.valueOf(entry[0].id).substring(0,15); // also fails with de-ref error
        opportunitylineitem.Quantity = 3;
        opportunitylineitem.UnitPrice = 5000;
        return opportunitylineitem;
   }
    
   public PageReference save() {
      // Add the opportunity line item to the database.       
      insert opportunitylineitem;
      // Send the user to the detail page for the new account.      
      PageReference oppPage = new ApexPages.StandardController(opportunity).view();
      oppPage.setRedirect(true);
      return oppPage;
   }
    
}
//////////////////////
Any guidance is appreciated.

 

Not sure how to go about this. There does not seem to be a getPriceBookEntry() getter built in.

 

When I attempt to reference the PriceBookVariable named entry, I get an error "Unknown Property."

 

In short, I want to look up price book entries and reference them on forms to add new products to an opportunity.

 

Visual Force:

 

<apex:page controller="addProductToOp002">
        <apex:form >
    <apex:pageBlock title="Retrieving Query String Parameters">
        You are viewing the {!opportunity.name} opportunity.
<br />
<br />
PriceBook2 = {!pricebook2.id}
<br />
<br />
PriceBookEntry = {!entry} // causes Unknown Property error
<br />
<br />
OpportunityLineItem data (Referenced from Add Products to Opportunity form):
<br />
OpportunityID = {!opportunitylineitem.OpportunityID}.
<br />
PriceBookEntryID = {!opportunitylineitem.PriceBookEntryID}.
<br />
Quantity = {!opportunitylineitem.Quantity}.
<br />
UnitPrice = {!opportunitylineitem.UnitPrice}.
<br />
<apex:inputField id="Quantity01uE0000000d3Y8" value="{!opportunitylineitem.Quantity}"/>
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!save}" value="Save"/>
      </apex:pageBlockButtons>

    </apex:pageBlock>
            </apex:form>
    </apex:page>

 

Apex Class:

 

public class addProductToOp002 {

  Opportunity opportunity;

  public Opportunity getOpportunity() {
        opportunity = [SELECT id, name, PriceBook2Id FROM Opportunity
                WHERE id = :ApexPages.currentPage().getParameters().get('id')];
        return opportunity;
    }
    
    PriceBook2 pricebook2;

    public PriceBook2 getPriceBook2() {    
        //pricebook2 = [SELECT id, name FROM PriceBook2 WHERE IsActive = true LIMIT 1];
        pricebook2 = [SELECT id, name FROM PriceBook2 WHERE id=:opportunity.PriceBook2Id LIMIT 1];
        return pricebook2;
    }

    PriceBookEntry entry;
    
    public PriceBookEntry getPriceBookEntry() {
        entry = [Select Id, name from PriceBookEntry where pricebook2id = :opportunity.PriceBook2Id LIMIT 1];
        return entry;
    }

    
    OpportunityLineItem opportunitylineitem;
    
    public OpportunityLineItem getOpportunityLineItem() {
        if(opportunitylineitem == null) opportunitylineitem = new OpportunityLineItem();

// QueryResult qr = binding.query("Select Id, name from PriceBook where IsActive = true");

        opportunitylineitem.OpportunityID = ApexPages.currentPage().getParameters().get('id');

        //01uE0000000d3Y8 is PriceBookEntryID from HTML <form> on Add Products to Opportunity page
        opportunitylineitem.PriceBookEntryID = '01uE0000000d3Y8';
        opportunitylineitem.Quantity = 3;
        opportunitylineitem.UnitPrice = 5000;

        return opportunitylineitem;
   }
    
   public PageReference save() {

      // Add the opportunity line item to the database.       
      insert opportunitylineitem;

      // Send the user to the detail page for the new account.      
      PageReference oppPage = new ApexPages.StandardController(opportunity).view();
      oppPage.setRedirect(true);

      return oppPage;
   }
    
}

 

 

I tried to post this earlier, but I cannot locate the post. (Sorry if this is a duplicate.)

 

I am trying to compile an example from the following apex code documentation:

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_dynamic_soql.htm|StartTopic=Content%2Fapex_dynamic_soql.htm|SkinName=webhelp

 

I keep receiving the above compile error when trying to create the Apex class shown below (and on the web page path above).

 

CODE SAMPLE:

 

 

 

public class SOQLController { 
    public String name { 
        get { return name;} 
        set { name = value;} 
    } 
    public PageReference query() { 
        String queryName = '%' + name + '%';
        queryResult = [SELECT Id FROM Contact WHERE 
           (IsDeleted = false and Name like :queryName)];
        return null; 
    } 

 

 

Thanks, Matt

On the SF Quote Page, I see that I can override Create PDF to show my own VIsualForce page. I can also "RenderAs" a PDF. This works as expected.

 

But how can I show my own VisualForce page in the pdfOverlay that is shown when the user clicks "Create PDF" when there is no override. In this case, a standard template is served up on the "pdfOverlay" window, with default buttons (Save to Quote, Save and Email Quote, and Cancel).

 

I want my Visualforce quote document to appear in that window, using those same buttons.

 

Basically, I want to use my own template via a VIsualforce page, rather than the more restrictive Templates available to us via the standard quote templates. The template layout options just don't seem to permit the coplexity I need. For example, it is not possible (I think) to create multi-page Terms & Conditions, and lengthy paragraph language to develop a longer form quotation to the customer.

 

Is there a simple way to reuse that PDF overlay with my own VIsualForce PDF, including the existing "Save to Quote" (etc.) buttons in the PDF Overlay ?

 

This would save me lots of time.

 

P.S. The SF Quote page's HTML source shows the following, which is why I thought pdfOverlay had some relevance:

 

HTML Snippet From SF Quote Page:

 

 

<input value="Create PDF"  class="btn" title="Create PDF" name="createpdf" onclick="null
 var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay'];pdfOverlay.dialog.buttonContents = '&lt;input value=\&quot;Save to Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;save\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');\&quot; title=\&quot;Save to Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Save and Email Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;saveAndEmail\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');\&quot; title=\&quot;Save and Email Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Cancel\&quot;  class=\&quot;btn\&quot; name=\&quot;cancel\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();\&quot; title=\&quot;Cancel\&quot; type=\&quot;button\&quot; /&gt;';
pdfOverlay.summlid = '0EHE0000000PCKI';
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id=0Q0E0000000TNLo','/quote/quoteTemplateHeaderData.apexp?id=0Q0E0000000TNLo');
pdfOverlay.display();
" type="button" />

Any advice to get to this solution? 

 

Thanks, Matt

 

On the SF Quote Page, I see that I can override Create PDF to show my own VIsualForce page. I can also "RenderAs" a PDF. This works as expected.

 

But how can I show my own VisualForce page in the pdfOverlay that is shown when the user clicks "Create PDF" when there is no override. In this case, a standard template is served up on the "pdfOverlay" window, with default buttons (Save to Quote, Save and Email Quote, and Cancel).

 

I want my Visualforce quote document to appear in that window, using those same buttons.

 

Basically, I want to use my own template via a VIsualforce page, rather than the more restrictive Templates available to us via the standard quote templates. The template layout options just don't seem to permit the coplexity I need. For example, it is not possible (I think) to create multi-page Terms & Conditions, and lengthy paragraph language to develop a longer form quotation to the customer.

 

Is there a simple way to reuse that PDF overlay with my own VIsualForce PDF, including the existing "Save to Quote" (etc.) buttons in the PDF Overlay ?

 

This would save me lots of time.

 

P.S. The SF Quote page's HTML source shows the following, which is why I thought pdfOverlay had some relevance:

 

HTML Snippet From SF Quote Page:

 

 

<input value="Create PDF"  class="btn" title="Create PDF" name="createpdf" onclick="null
 var pdfOverlay = QuotePDFPreview.quotePDFObjs['quotePDFOverlay'];pdfOverlay.dialog.buttonContents = '&lt;input value=\&quot;Save to Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;save\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'0\',\'0\');\&quot; title=\&quot;Save to Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Save and Email Quote\&quot;  class=\&quot;btn\&quot; name=\&quot;saveAndEmail\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').savePDF(\'1\');\&quot; title=\&quot;Save and Email Quote\&quot; type=\&quot;button\&quot; /&gt;&lt;input value=\&quot;Cancel\&quot;  class=\&quot;btn\&quot; name=\&quot;cancel\&quot; onclick=\&quot;QuotePDFPreview.getQuotePDFObject(\'quotePDFOverlay\').close();\&quot; title=\&quot;Cancel\&quot; type=\&quot;button\&quot; /&gt;';
pdfOverlay.summlid = '0EHE0000000PCKI';
pdfOverlay.setSavable(true);
pdfOverlay.setContents('/quote/quoteTemplateDataViewer.apexp?id=0Q0E0000000TNLo','/quote/quoteTemplateHeaderData.apexp?id=0Q0E0000000TNLo');
pdfOverlay.display();
" type="button" />

Any advice to get to this solution? 

 

Thanks, Matt

 

The following code is supposed to delete all products from the current Opportunity:

 

delete [ Select Id from OpportunityLineItem WHERE OpportunityID = :ApexPages.currentPage().getParameters().get('id') ];

 

...but it results in this error:

 

"DML currently not allowed"

 

The email generated to me from Salesforce about the error says:

System.LimitException: DML currently not allowed

 

Note: I am using Developer Edition.

 

Can anyone explain why this code is failing?

 

Thanks!

I have a class that inserts an OpportunityLineItem into an Opportunity.

The following statement is permitted:
    opportunitylineitem.PriceBookEntryID = '01uE0000000KoyD'; // literal is permitted
But the following statement results in an "Attempt to de-reference a null object" error
    opportunitylineitem.PriceBookEntryID = entry[0].id; // where entry is a LIST<PriceBookEntry> element
Investigating the PriceBookEntry table, I see that the PriceBookEntry ids are 18 characters long, where the literal permitted (and used on the usual Add Products to Opportunity page) is only 15 characters. I tried truncating the id via String.valueOf(entry[0].id).substring(0,15) but this causes the same de-reference error.
Is there a way to assign the id directly, or truncate it down to the needed 15 characters, without the dereference error? If I could get this, I'd be able to develop our solution further.
(Or am I missing something, a better approach.)
Here is the class. See the red highlighted lines.
//////////////////////
public class addProductToOp003 {
  Opportunity opportunity;
  
  public Opportunity getOpportunity() {
        opportunity = [SELECT id, name, PriceBook2Id FROM Opportunity
                WHERE id = :ApexPages.currentPage().getParameters().get('id')];
        return opportunity;
    }
    
    PriceBook2 pricebook2;
    public PriceBook2 getPriceBook2() {    
        pricebook2 = [SELECT id, name FROM PriceBook2 WHERE id=:opportunity.PriceBook2Id LIMIT 1];
        return pricebook2;
    }
    LIST<PriceBookEntry> entry;
    
    public LIST<PriceBookEntry> getEntry() {
        entry = [Select Id, name from PriceBookEntry where pricebook2id = :opportunity.PriceBook2Id ];
        return entry;
    }
    
    OpportunityLineItem opportunitylineitem;
    
    public OpportunityLineItem getOpportunityLineItem() {
        if(opportunitylineitem == null) opportunitylineitem = new OpportunityLineItem();
        opportunitylineitem.OpportunityID = ApexPages.currentPage().getParameters().get('id');
        //01uE0000000d3Y8 is PriceBookEntryID from HTML <form> on Add Products to Opportunity page
        //01uE0000000KoyD is a truncated ID from a different product in the PriceBookEntry table
        opportunitylineitem.PriceBookEntryID = '01uE0000000KoyD'; //'01uE0000000d3Y8'; // works as literal like this
        // opportunitylineitem.PriceBookEntryID = entry[0].id; // fails with de-reference error on visual force page
        // opportunitylineitem.PriceBookEntryID = String.valueOf(entry[0].id).substring(0,15); // also fails with de-ref error
        opportunitylineitem.Quantity = 3;
        opportunitylineitem.UnitPrice = 5000;
        return opportunitylineitem;
   }
    
   public PageReference save() {
      // Add the opportunity line item to the database.       
      insert opportunitylineitem;
      // Send the user to the detail page for the new account.      
      PageReference oppPage = new ApexPages.StandardController(opportunity).view();
      oppPage.setRedirect(true);
      return oppPage;
   }
    
}
//////////////////////
Any guidance is appreciated.

 

Not sure how to go about this. There does not seem to be a getPriceBookEntry() getter built in.

 

When I attempt to reference the PriceBookVariable named entry, I get an error "Unknown Property."

 

In short, I want to look up price book entries and reference them on forms to add new products to an opportunity.

 

Visual Force:

 

<apex:page controller="addProductToOp002">
        <apex:form >
    <apex:pageBlock title="Retrieving Query String Parameters">
        You are viewing the {!opportunity.name} opportunity.
<br />
<br />
PriceBook2 = {!pricebook2.id}
<br />
<br />
PriceBookEntry = {!entry} // causes Unknown Property error
<br />
<br />
OpportunityLineItem data (Referenced from Add Products to Opportunity form):
<br />
OpportunityID = {!opportunitylineitem.OpportunityID}.
<br />
PriceBookEntryID = {!opportunitylineitem.PriceBookEntryID}.
<br />
Quantity = {!opportunitylineitem.Quantity}.
<br />
UnitPrice = {!opportunitylineitem.UnitPrice}.
<br />
<apex:inputField id="Quantity01uE0000000d3Y8" value="{!opportunitylineitem.Quantity}"/>
      <apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!save}" value="Save"/>
      </apex:pageBlockButtons>

    </apex:pageBlock>
            </apex:form>
    </apex:page>

 

Apex Class:

 

public class addProductToOp002 {

  Opportunity opportunity;

  public Opportunity getOpportunity() {
        opportunity = [SELECT id, name, PriceBook2Id FROM Opportunity
                WHERE id = :ApexPages.currentPage().getParameters().get('id')];
        return opportunity;
    }
    
    PriceBook2 pricebook2;

    public PriceBook2 getPriceBook2() {    
        //pricebook2 = [SELECT id, name FROM PriceBook2 WHERE IsActive = true LIMIT 1];
        pricebook2 = [SELECT id, name FROM PriceBook2 WHERE id=:opportunity.PriceBook2Id LIMIT 1];
        return pricebook2;
    }

    PriceBookEntry entry;
    
    public PriceBookEntry getPriceBookEntry() {
        entry = [Select Id, name from PriceBookEntry where pricebook2id = :opportunity.PriceBook2Id LIMIT 1];
        return entry;
    }

    
    OpportunityLineItem opportunitylineitem;
    
    public OpportunityLineItem getOpportunityLineItem() {
        if(opportunitylineitem == null) opportunitylineitem = new OpportunityLineItem();

// QueryResult qr = binding.query("Select Id, name from PriceBook where IsActive = true");

        opportunitylineitem.OpportunityID = ApexPages.currentPage().getParameters().get('id');

        //01uE0000000d3Y8 is PriceBookEntryID from HTML <form> on Add Products to Opportunity page
        opportunitylineitem.PriceBookEntryID = '01uE0000000d3Y8';
        opportunitylineitem.Quantity = 3;
        opportunitylineitem.UnitPrice = 5000;

        return opportunitylineitem;
   }
    
   public PageReference save() {

      // Add the opportunity line item to the database.       
      insert opportunitylineitem;

      // Send the user to the detail page for the new account.      
      PageReference oppPage = new ApexPages.StandardController(opportunity).view();
      oppPage.setRedirect(true);

      return oppPage;
   }
    
}

 

 

I tried to post this earlier, but I cannot locate the post. (Sorry if this is a duplicate.)

 

I am trying to compile an example from the following apex code documentation:

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_dynamic_soql.htm|StartTopic=Content%2Fapex_dynamic_soql.htm|SkinName=webhelp

 

I keep receiving the above compile error when trying to create the Apex class shown below (and on the web page path above).

 

CODE SAMPLE:

 

 

 

public class SOQLController { 
    public String name { 
        get { return name;} 
        set { name = value;} 
    } 
    public PageReference query() { 
        String queryName = '%' + name + '%';
        queryResult = [SELECT Id FROM Contact WHERE 
           (IsDeleted = false and Name like :queryName)];
        return null; 
    } 

 

 

Thanks, Matt