• etess
  • NEWBIE
  • 55 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 17
    Replies

I have a custom VF page that is using the standard Opportunity controller and an extension. In the VF page, I'm displaying OpportunityContactRoles in a Data Table so that I can have some additional columns/information displayed that are not options within the standard OpportunityContactRoles related list. My problem is that I have to manually add in the Del link (that appears in the "Action" column on the Opportunity Contact Roles related list) but can't seem to figure out the URL to use.

 

I see that the Del button links to /setup/own/deleteredirect.jsp with the following parameters:

  • id --> opportunity id
  • delID --> opportunitycontactrole id to delete
  • retURL --> the return URL
  • _CONFIRMATIONTOKEN --> ??

What is the confirmation token, and how do I determine it?

If there is an easier way to approach this rather than hacking the URL myself please let me know.

  • May 11, 2011
  • Like
  • 0

I have a controller (ex. myController) with a method (ex. mailMyContact), that when called, sends an e-mail (Messaging.SingleEmailMessage) with a PDF attachment (saved from a VF page). This is working fine in the Sandbox - the method is called from a User button click from a visualforce page. However, I can't figure out how to test it. I'm trying the below - when I comment out the third line it the coverage covers the other method, but when I include it, it's not getting any coverage. Is there a trick to testing Single Email Messages and/or PDF attachments?

 

 

myController c = new myController();
c.updateContact();
c.mailMyContact();

 

 

  • May 03, 2011
  • Like
  • 0

Was just wondering if anyone knows what happens when an autonumber field hits its limit (ex: if a one digit auto number gets to 9, what happens next?). Does it error out?

  • March 22, 2011
  • Like
  • 0

In the help section for Chatter, it says there is a limit on the "length of time posts, comments, and tracked field changes are stored on the Salesforce servers." Anyone know where I can find information on what exactly those limits are? Thanks!

  • March 04, 2011
  • Like
  • 0

I was wondering if there is a simple way on a VisualForce page to check the current user's permissions for that particular Record (ie Read or Edit). I have some buttons that I'd like to have the visibility dependent on the User's permissions, but I'm currently setting visibility based on their Profile or Role. This is fine - but a little tedious. Is there was a simple way to see if User can Read or User can Read/Write?

  • January 18, 2011
  • Like
  • 0

Is there a way to control a record's visibility to a user based on the Opportunity Stage? For my organization, I want to have Opportunities that are Closed Won visible to all, but if they are still in the potential stages (prospecting, etc), only the Opportunity Owner and their superiors should be able to view that. Happy to code whatever I need to make this happen, but would love some pointers on whether it is even possible and if so, strategy to achieve that.

 

Thanks!

  • January 18, 2011
  • Like
  • 0

I would like to create a validation rule that permits only Standard Users or Opportunity Owners to be able to change the ownership of an Opportunity. I created the following Validation rule on Opportunity owner:

 

 

AND(ISCHANGED( OwnerId ) , NOT(OR($Profile.Name == 'Standard User', OwnerId == $User.Id )))

 

 

However, it's not working. My test (on a System Admin profile) was to change an Opportunity not owned by me to me. I think it is failing because OwnerId is refering to the NEW value of the Opportunity Owner field, rather than the old value.

 

How do I get this working?

  • January 06, 2011
  • Like
  • 0

I have a Change Set that I'm trying to deploy from my Sandbox. My classes all work properly and my Test methods are getting appropriate coverage in the Sandbox. However, when I try to validate the Inbound Change Set on my production site I get an error that isn't appearing in my Sandbox:

 

quoteExtentionTest2.QuotePdfTest() Line 98

Failure Message: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, This field is required: [VersionData]", Failure Stack Trace: "Class.quoteExtension.quoteSave: line 98, column 9 Class.quoteExtentionTest2.QuotePdfTest: line 64, column 9 External entry point"

 

The line of code generating the error is inserting a QuoteDocument object; I used http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_quotedocument.htm as my reference for what fields are required. VersionData seems to be a field for a ContentVersion object - which is an object I am not dealing with currently. How do I deal with that error?

  • January 03, 2011
  • Like
  • 0

I have a VF Page called "bidPDFPreview" which I'd like to use as a "Preview PDF" page; it has an inline frame of a VF PDF called bidPDF. This all displays properly. I have a button that executes an APEX method to save the bidPDF as a QuoteDocument and redirect to the PDF. However, I am getting the following error upon executing my Save Method:

 

SObject row was retrieved via SOQL without querying the requested field: (fields on my bidPDF page)

 

 

My APEX Class is below, with the problem line of code bolded: (When I comment out that line, the button correctly just brings up the PDF). For simplicity's sake, I removed the code that actually creates the QuoteDocument from the Blob and inserts it since that is not what is causing this issue.

 

public class quoteExtension {

private final Quote qte;

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

public PageReference quoteSave(){

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id);
QuotePDFPage.setRedirect(true);
Blob QuotePDFBlob = QuotePDFPage.getContentAsPDF();
return QuotePDFPage;

}

}

 

Also note the bidPDF page is set to display as a PDF, and that Blob definition fails using both .getContentAsPDF() and .getContent()

 

When I add hidden fields onto my bidPDFPreview page, it seems to help (it starts showing errors for different fields), but it seems excessive to duplicate and hide all the code on my bidPDF page into the preview to make this work.

  • December 23, 2010
  • Like
  • 0

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;

}

}

 

 

  • December 20, 2010
  • Like
  • 0

I've created a custom VF PDF page for Quotes. I'd like to replace the standard PDF template with my VF page. However, when I override the "Create PDF" button with my VF page, it simply displays the PDF but doesn't allow me to Save or E-mail it.

 

How can I maintain the PDF Preview window, or at the very least just make sure the PDF gets saved and added to the "Quote PDFs" related list? I can't seem to find any documentation on strategies for this.

  • December 13, 2010
  • Like
  • 0

I am new to Apex and not quite sure the syntax for passing a variable into one of my methods from a Visualforce page. I have an apex:repeat loop on my VF page that I'd like to perform a call to one of my apex methods within.

 

The VF page loop looks like this:

 

<apex:repeat value="{!ListCategories}" var="this">
   {!this.name} - SUBTOTAL HERE <br/>
</apex:repeat>

 

 The method looks like this:

 

 

 

Public Decimal calcSubtotal(String Category) {
     Decimal count = 0;

     for (QuoteLineItem a : [select category__c, UnitPrice from QuoteLineItem where category__c = :Category AND Quote.Opportunity.Id = :qte.Opportunity.Id]) {       
          count += a.UnitPrice;
     }
        
     return count;
}

 

What I want to do is replace where it says "SUBTOTAL HERE" on my VF page with the subtotal for that particular category. What I can't seem to figure out is how do I pass the "this.name" variable from my VF loop into my calcSubtotal method? The Standard controller is Quote and this method is a controller extension.

 

  • December 13, 2010
  • Like
  • 0

I am using apex:repeat to display a related list, but I'd like to only display unique results. How do I achieve this?

 

Just for some frame of reference - It's a list of a custom object (OBJ) that is related to my Quote Line Items, so multiple Quote Line Items may be related to the same OBJ - I want to list out all the OBJs referenced in the Line Items without it displaying duplicates if its related to more than one line item.

  • December 10, 2010
  • Like
  • 0

I'd like to have a link back to the previous page on my custom VF page that I'm using to override the standard Opportunity page. How do I do this? It can either go back to the last page the user was viewing or Back to Opportunity List.

 

Also - my VF page is tabbed; not sure how that affects things. Thanks.

  • December 02, 2010
  • Like
  • 0

I am trying to create a VF page that will eventually be rendered as a PDF.  I have a Related list that displays correctly using apex:relatedList, however, I am trying to display it using apex:repeat or apex:dataList so that I can format the PDF. But when I try to use apex:repeat or apex:dataList, I get the following error:

 

Error: ; nested exception is: common.exception.ApiQueryException: ....... If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

I know I am referring to the custom relationship correctly because the Related List displays.

 

The standard controller is Quote. The related list is Custom Objects that are children of the Opportunity.

 

  • My related list code looks like this:
         <apex:relatedList list="{!quote.Opportunity.CustOBJ__r}"}
  • My apex:repeat looks like this:
         <apex:repeat value="{!quote.Opportunity.CustOBJ__r}" var="cx">
            <apex:outputText value="{!cx.name}"/>
        </apex:dataList>

Any ideas why this would be happening?

  • November 23, 2010
  • Like
  • 0

My Opportunity Products have a custom Lookup field to a custom object; I've placed a filter on that field to limit results to objects that are the child of the Opportunity we are adding Opportunity Products to. This works perfectly fine when Editing a Opportunity Product. My filter is making sure the Custom Object's parent Opportunity ID equals the Opportunity Product's Opportunity ID.

 

However, it fails when adding a new Opportunity Product. When you get to the multilineitem.jsp page, clicking on the LookUp icon doesn't respond at all - it won't even open the LookUp search window.

 

My thinking is that maybe the Opportunity ID doesn't get passed to multilineitem.jsp? Any insights into how to get around this issue?

  • November 18, 2010
  • Like
  • 0

I have a visual force page with an Opportunity standard controller.

 

The following code displays the proper information, but is not displaying as a link to that Account.  However, my custom lookup fields to other accounts are displaying properly and linked to their respective Account records. What am I missing here?

 

<apex:outputField value="{!opportunity.Account.name}"/>

 

 

  • November 18, 2010
  • Like
  • 0

I am more or less happy with the Account page layout I created through the page layout editor (Setup >> Customize >> Accounts >> Page Layout) - however, I'd like to either insert a Visualforce page inline with that layout, or Clone that page layout into a fresh Visualforce page I can edit. Is there any way to do this without writing the entire visualforce markup for that page layout from scratch?

  • November 16, 2010
  • Like
  • 0

I'm new to Visualforce and APEX;

 

Here is some background on what I am trying to do - Each Account is assigned either "Agency" or "Client" picklist values under the "Type" field. (I am using Professional edition, so I am not able to create different Account Record Types). My company's Opportunities always relate to TWO Accounts - one of each type. I currently have the Opportunity Account Name field looking up Agency Accounts and a custom look up field to assign the Client Account.

 

The issue I have is displaying redundant Related Lists on the Account Page - for "Agency" accounts, this is fine.. the Opportunities show up under "Opportunities" related list. For Client Accounts, however, the related Opportunities display on a separate related list created by the custom look up field.

 

Any direction on the best way to tackle this is appreciated - below I've listed my ideas, but I don't know how to execute any of them (I'm shuffling around in the Visualforce inline page documentation but quite confused...) Also - please let me know if what I am trying to do requires Enterprise.

-HIDE empty related list

-DISPLAY related list based on Account Type Field value (using an inline visualforce page?)

-restructure how i point opportunities to multiple accounts..

  • November 16, 2010
  • Like
  • 0

I have a custom VF page that is using the standard Opportunity controller and an extension. In the VF page, I'm displaying OpportunityContactRoles in a Data Table so that I can have some additional columns/information displayed that are not options within the standard OpportunityContactRoles related list. My problem is that I have to manually add in the Del link (that appears in the "Action" column on the Opportunity Contact Roles related list) but can't seem to figure out the URL to use.

 

I see that the Del button links to /setup/own/deleteredirect.jsp with the following parameters:

  • id --> opportunity id
  • delID --> opportunitycontactrole id to delete
  • retURL --> the return URL
  • _CONFIRMATIONTOKEN --> ??

What is the confirmation token, and how do I determine it?

If there is an easier way to approach this rather than hacking the URL myself please let me know.

  • May 11, 2011
  • Like
  • 0

I have a controller (ex. myController) with a method (ex. mailMyContact), that when called, sends an e-mail (Messaging.SingleEmailMessage) with a PDF attachment (saved from a VF page). This is working fine in the Sandbox - the method is called from a User button click from a visualforce page. However, I can't figure out how to test it. I'm trying the below - when I comment out the third line it the coverage covers the other method, but when I include it, it's not getting any coverage. Is there a trick to testing Single Email Messages and/or PDF attachments?

 

 

myController c = new myController();
c.updateContact();
c.mailMyContact();

 

 

  • May 03, 2011
  • Like
  • 0

I would like to create a validation rule that permits only Standard Users or Opportunity Owners to be able to change the ownership of an Opportunity. I created the following Validation rule on Opportunity owner:

 

 

AND(ISCHANGED( OwnerId ) , NOT(OR($Profile.Name == 'Standard User', OwnerId == $User.Id )))

 

 

However, it's not working. My test (on a System Admin profile) was to change an Opportunity not owned by me to me. I think it is failing because OwnerId is refering to the NEW value of the Opportunity Owner field, rather than the old value.

 

How do I get this working?

  • January 06, 2011
  • Like
  • 0

I have a VF Page called "bidPDFPreview" which I'd like to use as a "Preview PDF" page; it has an inline frame of a VF PDF called bidPDF. This all displays properly. I have a button that executes an APEX method to save the bidPDF as a QuoteDocument and redirect to the PDF. However, I am getting the following error upon executing my Save Method:

 

SObject row was retrieved via SOQL without querying the requested field: (fields on my bidPDF page)

 

 

My APEX Class is below, with the problem line of code bolded: (When I comment out that line, the button correctly just brings up the PDF). For simplicity's sake, I removed the code that actually creates the QuoteDocument from the Blob and inserts it since that is not what is causing this issue.

 

public class quoteExtension {

private final Quote qte;

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

public PageReference quoteSave(){

PageReference QuotePDFPage = new PageReference('/apex/bidPDF?id='+qte.Id);
QuotePDFPage.setRedirect(true);
Blob QuotePDFBlob = QuotePDFPage.getContentAsPDF();
return QuotePDFPage;

}

}

 

Also note the bidPDF page is set to display as a PDF, and that Blob definition fails using both .getContentAsPDF() and .getContent()

 

When I add hidden fields onto my bidPDFPreview page, it seems to help (it starts showing errors for different fields), but it seems excessive to duplicate and hide all the code on my bidPDF page into the preview to make this work.

  • December 23, 2010
  • Like
  • 0

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;

}

}

 

 

  • December 20, 2010
  • Like
  • 0

I am new to Apex and not quite sure the syntax for passing a variable into one of my methods from a Visualforce page. I have an apex:repeat loop on my VF page that I'd like to perform a call to one of my apex methods within.

 

The VF page loop looks like this:

 

<apex:repeat value="{!ListCategories}" var="this">
   {!this.name} - SUBTOTAL HERE <br/>
</apex:repeat>

 

 The method looks like this:

 

 

 

Public Decimal calcSubtotal(String Category) {
     Decimal count = 0;

     for (QuoteLineItem a : [select category__c, UnitPrice from QuoteLineItem where category__c = :Category AND Quote.Opportunity.Id = :qte.Opportunity.Id]) {       
          count += a.UnitPrice;
     }
        
     return count;
}

 

What I want to do is replace where it says "SUBTOTAL HERE" on my VF page with the subtotal for that particular category. What I can't seem to figure out is how do I pass the "this.name" variable from my VF loop into my calcSubtotal method? The Standard controller is Quote and this method is a controller extension.

 

  • December 13, 2010
  • Like
  • 0

I am trying to create a VF page that will eventually be rendered as a PDF.  I have a Related list that displays correctly using apex:relatedList, however, I am trying to display it using apex:repeat or apex:dataList so that I can format the PDF. But when I try to use apex:repeat or apex:dataList, I get the following error:

 

Error: ; nested exception is: common.exception.ApiQueryException: ....... If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

 

I know I am referring to the custom relationship correctly because the Related List displays.

 

The standard controller is Quote. The related list is Custom Objects that are children of the Opportunity.

 

  • My related list code looks like this:
         <apex:relatedList list="{!quote.Opportunity.CustOBJ__r}"}
  • My apex:repeat looks like this:
         <apex:repeat value="{!quote.Opportunity.CustOBJ__r}" var="cx">
            <apex:outputText value="{!cx.name}"/>
        </apex:dataList>

Any ideas why this would be happening?

  • November 23, 2010
  • Like
  • 0

I'm new to Visualforce and APEX;

 

Here is some background on what I am trying to do - Each Account is assigned either "Agency" or "Client" picklist values under the "Type" field. (I am using Professional edition, so I am not able to create different Account Record Types). My company's Opportunities always relate to TWO Accounts - one of each type. I currently have the Opportunity Account Name field looking up Agency Accounts and a custom look up field to assign the Client Account.

 

The issue I have is displaying redundant Related Lists on the Account Page - for "Agency" accounts, this is fine.. the Opportunities show up under "Opportunities" related list. For Client Accounts, however, the related Opportunities display on a separate related list created by the custom look up field.

 

Any direction on the best way to tackle this is appreciated - below I've listed my ideas, but I don't know how to execute any of them (I'm shuffling around in the Visualforce inline page documentation but quite confused...) Also - please let me know if what I am trying to do requires Enterprise.

-HIDE empty related list

-DISPLAY related list based on Account Type Field value (using an inline visualforce page?)

-restructure how i point opportunities to multiple accounts..

  • November 16, 2010
  • Like
  • 0