• sf42_Tobi
  • NEWBIE
  • 25 Points
  • Member since 2009

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

I have created a component that is using a custom class.  I added this component to an email template.  When I try and load the template this is the error message I receive. List has no rows for assignment to SObject. From what I can tell the attribute I have created is not passing the value to my class.

 

Also, when I first pull up the task page to send an email, the OpportunityID is part of the querystring with a key of p3_lkid. However, when I select the template the querystring is reset.  I have enclosed the relevant code below.

 

 

Component

 <apex:component access="global" controller="ProbeQuoteEmail">
<apex:attribute name="opportunityID"
description="This is the ID of the opportunity."
type="ID" assignTo="{!opportunityID}" />

<apex:repeat value="{!ProbeProducts}" var="p">
<p>{!p.ProductFamily__c}</p>
<table border='1'>
<apex:repeat value="{!p.OpportunityLineItems}" var="line">

<tr>
<td ><apex:outputText value="{!line.Quantity}"/></td>
<td ><apex:outputText value="{!line.PricebookEntry.Name}"/></td>
<td align="right"><apex:outputField value="{!line.UnitPrice}"/></td>
<td align="right"><apex:outputField value="{!line.TotalPrice}"/></td>
</tr>

</apex:repeat>
</table>
</apex:repeat>

</apex:component>


Email Template


<messaging:emailTemplate subject="Your requested quote n° {!relatedTo.Id}" recipientType="Contact" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
Dear {!recipient.name},

Thank you for your continued interest in our offering. Please see the attached quote per your request.

Feel free to contact me if you have any questions.

Regards,
{!$User.FirstName} {!$User.LastName}

</messaging:plainTextEmailBody>
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">

<c:ProbeQuoteProducts opportunityID="{!relatedTo.Id}"/>

</messaging:attachment>


</messaging:emailTemplate>

Apex Class


public class ProbeQuoteEmail {
Schema.DescribeFieldResult F = Product2.Family.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();

public Opportunity Probe { get; set; }

public Id opportunityID { get; set; }

public List<Opportunity> ProbeProducts = new List<Opportunity>();

Integer Counter = 1;

public ProbeQuoteEmail() {

for (Schema.PicklistEntry fam:P){
Integer i = 0;
String FamilyLabel = fam.GetLabel();

Probe = [SELECT o.Id, o.Name, o.Amount, o.ProductFamily__c, (SELECT op.Quantity, op.UnitPrice, op.TotalPrice,
op.PricebookEntry.Name, op.OpportunityId, op.PricebookEntry.ProductCode,
op.PricebookEntry.Product2.Family, op.LineCount__c
FROM OpportunityLineItems op WHERE op.PricebookEntry.Product2.Family = :FamilyLabel)
FROM Opportunity o where Id = :opportunityID];

Probe.Amount = 0;
Probe.ProductFamily__c = FamilyLabel;

for(i=0;i<Probe.opportunityLineItems.size();i++) {
Probe.Amount += Probe.opportunityLineItems[i].TotalPrice;
Probe.opportunityLineItems[i].LineCount__c = Counter;
Counter++;
}

ProbeProducts.add(Probe);
}
}

public List<Opportunity> getProbeProducts() {
return ProbeProducts;
}


}
Message Edited by sgottreu on 07-01-2009 01:26 PM
Message Edited by sgottreu on 07-01-2009 02:15 PM

Hi there,

 

I'm experiencing a strange problem. In a Visualforce Page there is a large number of custom buttons. They were implemented as <apex:commandLink> and work well in Firefox, Safari, Opera, Internet Explorer 7.

But the same button doesn't work in IE 8! I tried the Developertools from the extras menu in IE 8 and opened the page in IE 7 mode, everything works as expected.

I also tried to change the <apex:commandLink> in a <apex:commandButton>, but there is no reaction.

The action invoked is just similar to any other working Button (a simple pageReference which sets a field value).


Is there any known problem or a workaround to fix this problem?

 

Any suggestions welcome ;-)

 

Best regards,

Tobias Forstmeier

I was trying to update the code of our managed package. The Force IDE worked as usual, but after a refresh there were no changes on the code.

I tried to edit the Visualforce directly within the org and edited it by hand. After Saving without any errors I refreshed the code and there were also no changes!

 

Does anyone else have these problems since the rollback of the Spring 10 release?

 

Is there any tipp on how to save anyway?

 

I opened a case in the partner portal, but there are 4 Bugs with status new since the last 3 weeks without any reaction?!

Hi,

 

I've implemented a function to replace the current OpportunityLineItems by a list of custom objects. The method works fine most the time, but since one week, I receive error Mails from time to time.

 

System.DmlException: Delete failed. First exception on row 0 with id 00k2000000xxXxxXXX; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

 

I tried many times, but wasn't able to reproduce this error. But it occurs from different users with different profiles. When I try to call the Object with the ID from the Email, salesforce says "data not available", so the delete must have worked in a way. Here is a code snippet, the selectedLineItems are generated on page load, the method is called from a button inside the visualforce page:

 

 

public void copyLineItems() {
id opptyId = quote.SF42_QuoOpportunity__r.id;
if (opptyId == null) {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,err_noO));
}
else if (selectedLineItems == null) {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,err_q2o));
}
else {
// get actual OppLineItems
List<OpportunityLineItem> oldLineItems = [Select id from OpportunityLineItem where opportunityId = :opptyId];
// create new OppLineItems
List<OpportunityLineItem> newLineItems = new List<OpportunityLineItem>();
for (SF42_GenLineItem__c s: selectedLineItems){
if (s.SF42_QuoLI_PriceBookEntryId__c != NULL) {
newLineItems.add(New OpportunityLineItem(
OpportunityId = opptyId,
Quantity = (double) s.get('Quantity__c'),
UnitPrice = (Double) s.get('Unitprice__c'),
Description = (string)s.get('Description__c'),
pricebookEntryId = (Id) s.get('pricebookEntryId__c')
));
}
}
// replace current line items with Opp line items and update Opp
if (newLineItems.size() > 0) {

// ERROR OCCURS IN THE FOLLOWING LINE

delete oldLineItems;

insert newLineItems;
opp.Field1__c = myobject.Field1__c;
opp.Field2__c = myobject.Field2__c;
opp.Field3__c = myobject.Field3__c;
update opp;
}
else {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,err_q2o));
}
}
}

 Can anyone give advice to this problem?

 

Thanks in advance,

Tobias

 

 

I have an ExportContacts.page defined like this:

 

 

<apex:page standardController="Contact" contenttype="application/vnd.ms-excel#ExportContacts.xls" 
recordSetVar="contacts" extensions="ExportContactsExtension" >
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!contacts}" var="contact">
         <apex:column value="{!contact.LastName}"/>
         <apex:column value="{!contact.FirstName}"/>
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
         <apex:column value="{!contact.Fax}"/>
         <apex:column value="{!contact.MobilePhone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

 

 

I have a custom button on my page and can export the contacts to Excel.  The issue is that some entries with multi-line addresses like:

 

 

123 Main Street
Suite 100

 get put into two rows in the same column - the main entry will be two rows high as the cells are merged, but the address is not in a merged cell but instead in two separate rows.  For example, the name will be in Cell C31/32 (merged cell), but the address will be in Cells J31 and J32 as separate cells, not merged.

 

 

The issue is the merged cells prevent sorting, but even if the cells are unmerged, the address will be on separate rows so it won't remain with the original entry when sorting.  How can I export this data to Excel without these merged cells?

  • September 15, 2010
  • Like
  • 0

Hi,

 

I have created some batch apex code alongwith other triggers and class/controller codes. 

 

When I run individual test methods on them, I am able to get test success result alongwith nice code coverage %. However when I run all tests together, I get following test failure errors:-

 

1)System.AsyncException: Database.executeBatch cannot be called from a batch or future method.

2)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

3)System.AsyncException: Future method cannot be called from a future method: getLead_Rollup_Amount(Id)

4)System.AsyncException: Future method cannot be called from a future method: changeOwners(String, String)

 

Please note again that the exceptions dont come when tested individually.

 

Please advise on same.

 

 

Thanks,

 

Vimal 

I have created a component that is using a custom class.  I added this component to an email template.  When I try and load the template this is the error message I receive. List has no rows for assignment to SObject. From what I can tell the attribute I have created is not passing the value to my class.

 

Also, when I first pull up the task page to send an email, the OpportunityID is part of the querystring with a key of p3_lkid. However, when I select the template the querystring is reset.  I have enclosed the relevant code below.

 

 

Component

 <apex:component access="global" controller="ProbeQuoteEmail">
<apex:attribute name="opportunityID"
description="This is the ID of the opportunity."
type="ID" assignTo="{!opportunityID}" />

<apex:repeat value="{!ProbeProducts}" var="p">
<p>{!p.ProductFamily__c}</p>
<table border='1'>
<apex:repeat value="{!p.OpportunityLineItems}" var="line">

<tr>
<td ><apex:outputText value="{!line.Quantity}"/></td>
<td ><apex:outputText value="{!line.PricebookEntry.Name}"/></td>
<td align="right"><apex:outputField value="{!line.UnitPrice}"/></td>
<td align="right"><apex:outputField value="{!line.TotalPrice}"/></td>
</tr>

</apex:repeat>
</table>
</apex:repeat>

</apex:component>


Email Template


<messaging:emailTemplate subject="Your requested quote n° {!relatedTo.Id}" recipientType="Contact" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
Dear {!recipient.name},

Thank you for your continued interest in our offering. Please see the attached quote per your request.

Feel free to contact me if you have any questions.

Regards,
{!$User.FirstName} {!$User.LastName}

</messaging:plainTextEmailBody>
<messaging:attachment renderAs="pdf" filename="{!relatedTo.name}">

<c:ProbeQuoteProducts opportunityID="{!relatedTo.Id}"/>

</messaging:attachment>


</messaging:emailTemplate>

Apex Class


public class ProbeQuoteEmail {
Schema.DescribeFieldResult F = Product2.Family.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();

public Opportunity Probe { get; set; }

public Id opportunityID { get; set; }

public List<Opportunity> ProbeProducts = new List<Opportunity>();

Integer Counter = 1;

public ProbeQuoteEmail() {

for (Schema.PicklistEntry fam:P){
Integer i = 0;
String FamilyLabel = fam.GetLabel();

Probe = [SELECT o.Id, o.Name, o.Amount, o.ProductFamily__c, (SELECT op.Quantity, op.UnitPrice, op.TotalPrice,
op.PricebookEntry.Name, op.OpportunityId, op.PricebookEntry.ProductCode,
op.PricebookEntry.Product2.Family, op.LineCount__c
FROM OpportunityLineItems op WHERE op.PricebookEntry.Product2.Family = :FamilyLabel)
FROM Opportunity o where Id = :opportunityID];

Probe.Amount = 0;
Probe.ProductFamily__c = FamilyLabel;

for(i=0;i<Probe.opportunityLineItems.size();i++) {
Probe.Amount += Probe.opportunityLineItems[i].TotalPrice;
Probe.opportunityLineItems[i].LineCount__c = Counter;
Counter++;
}

ProbeProducts.add(Probe);
}
}

public List<Opportunity> getProbeProducts() {
return ProbeProducts;
}


}
Message Edited by sgottreu on 07-01-2009 01:26 PM
Message Edited by sgottreu on 07-01-2009 02:15 PM

Hi,

 

 

I have created an email template that generates a PDF document. The document gets data from an Object record which contains a Long Text field. Because of this field, it is impossible to know just how many pages the PDF document will be.

 

What I would like to do is have a way that for every page within the PDF document, the company logo appears in the background in the top left corner as well as another image appearing in the bottom right corner.

 

Does anyone know if something like this is possible? I am struggling to come up with a solution to this problem.

 

Thanks in advance

Warren

Hi-

 

I'm struggling with the best way to approach something in Visualforce, any thought appreciated.

 

Our postroom folk would like a nice simple UI for logging the outgoing post. 

Each post item they log is a detail custom object belonging to an opportunity.

I have no problem creating a VF page for doing one item at a time.

 

What I'm struggling with is creating a page that allows them to set two or three common fields, enter up to ten rows of data and push the button to have ten almost-identical items created and associated with the appropriate opportunities.   Ten is a number that's "comfortable" on screen for them, in case anyone says "Why ten?" 

 

Since I'm dealing with multiple items and multiple "parent" opportunities, I can't use most of the pre-defined apex form components, which all tie back to one ID.

 

Right now, I'm exploring the idea of having HTML form items, and building the items in javascript to insert via API calls.  This is causing me problems with permission denied errors on picklist values, trying to work out indirect references to form elements rather than hardcode each item in the form, and a plague of other things.

 

Has anyone run into this type of idea before, and have any insight they can share on how to approach it please?

 

My first "evil half-breed" page of code looks like this, and it doesn't even approach working, but may give an idea of what I was thinking:

 

<apex:page standardcontroller="Disbursement__c"> <head> <link href="/sCSS/Theme2/en/common.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/12.0/connection.js"></script> <script type="text/javascript"> function PostThePost(form) { // Build an array of disbursements for the post items. var PostItem = new sforce.SObject("Disbursement__c"); var PostPile = new Array(PostItem); // Build an array of Tasks to enter completed tasks for return of docs var PostLog = new sforce.Sobject("Task"); var LogPile = new Array(PostLog); // Create a holder for the query returned records var Record = new Array(); // Create the basic query string var Querystub = "Select Id from Opportunity Where Claim_ref__c = " // Cycle through the inputs for (var x = 0; x < 10; x++) {

// TODO: check that the form field has data before triyng to query, we might only need to do 1 query of the ten.. // Find the relevant opportunityId by querying for it- this needs to be indirect, so if x=0 query T1, x=1 query T2 etc var saveResult = sforce.connection.query(Querystub+eval(form.+'T'+x+1+'.value')); // If it returned a record, it will be one- Claim_ref__c is a unique field if (saveResult.size != 0){ // grab the record Record = saveResult.records; //Put the opportunity ID into the new disbursement record. PostPile[x].Disbursements__c = Record.Id; //Fill in the postage type picklist field PostPile[x].Postage_type__c = form.Type_of_post.value; //The record type ID is constant for postage disbursements PostPile[x].RecordTypeId = '012200000004w5OAAQ'; //Set the field of the label, in theory only if postage type is registered or special delivery PostPile[x].Post_tracking__c = eval(form.+'T'+x+11+'.value');

// TODO: place an "OK" next to the relevant item, clear the field entry to prevent duplication,

// and if the checkbox is ticked, create a Task on the opportunity, subject "Docs returned" that is complete. } } //Shovel with an update var didTheUpdateWork = sforce.create(PostPile); // Do any cleanup and error catching we need to, TODO

// TODO Wait for use to do their thing, then //Get back to the Leads tab that this user invariably lives on //window.parent.location.href="{! urlFor( $Action.Lead.Tab , $ObjectType.Lead,null,true)}"; } </script> </head> This is the Outgoing post form<br></br> Designed to enter disbursements for outgoing post, and log a completed task for document returns. <br></br> <br></br> <form name="PostForm" method="POST" action="" class="dataCol"> <select name="Type_of_post" size="1" class="requiredBlock"> <option value="First class">First class</option> <option value="Second class">Second class</option> <option value="Registered">First class, Registered Signed for</option> <option value="Second class, Registered Signed for">Second class, Registered Signed For</option> <option value="Special Delivery next day">Special Delivery next day</option> <option value="Special Delivery before 9am">Special Delivery before 9am</option> </select> Tick here if these are doc returns <input type="checkbox" name="C1" value="ON"/><br></br> <table cols="2"> <tr><td>Case number&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td> <td>Label number for Registered/SD</td></tr> <tr class="dataCol col02"><td><input type="text" name="T1" size="6"/></td><td><input type="text" name="T11" size="10"/></td></tr> <tr><td><input type="text" name="T2" size="6"/></td><td><input type="text" name="T12" size="10"/></td></tr> <tr><td><input type="text" name="T3" size="6"/></td><td><input type="text" name="T13" size="10"/></td></tr> <tr><td><input type="text" name="T4" size="6"/></td><td><input type="text" name="T14" size="10"/></td></tr> <tr><td><input type="text" name="T5" size="6"/></td><td><input type="text" name="T15" size="10"/></td></tr> <tr><td><input type="text" name="T6" size="6"/></td><td><input type="text" name="T16" size="10"/></td></tr> <tr><td><input type="text" name="T7" size="6"/></td><td><input type="text" name="T17" size="10"/></td></tr> <tr><td><input type="text" name="T8" size="6"/></td><td><input type="text" name="T18" size="10"/></td></tr> <tr><td><input type="text" name="T9" size="6"/></td><td><input type="text" name="T19" size="10"/></td></tr> <tr><td><input type="text" name="T10" size="6"/></td><td><input type="text" name="T20" size="10"/></td></tr></table> <p>&nbsp;</p> <input type="button" value="Submit Post" onclick="PostThePost(this.form)" name="B1" class="btn"/><input type="reset" value="Reset" name="B2" class="btn"/> </form></apex:page>

 

Thanks,

Nick

Message Edited by bunrotha on 01-21-2009 06:52 AM
Sorry if this is way too basic but I've been pouring over all of the books I got at dreamforce and the online docs and cannot figure this out.

I'm creating a Visualforce page for a custom object called "Override".  At minimum I'd like the user to be able to insert an Override record on this page (in one row).  However, all I can see in the docs is how to create a page that displays existing records and perform mass updates to them:

Code:
<apex:page standardController="Override__c" recordSetVar="overrides">
<apex:sectionHeader title="Overrides"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock id="pageRowInsert">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton action="{!Save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!overrides}" var="ovr">
               <apex:column ><apex:inputField value="{!ovr.Advisor_Rep__c}"  /></apex:column>
                <apex:column ><apex:inputField value="{!ovr.Institution__c}"  /></apex:column>
                <apex:column headerValue="Opportunity" value="{!ovr.Opportunity__c}"></apex:column>
                <apex:column headerValue="Override Amount" value="{!ovr.Override_Amount__c}"></apex:column>               
            </apex:pageBlockTable>
        </apex:pageBlock>
   </apex:form>
</apex:page>

How do I tell the system that I want empty  inputFields so that I can Insert a record?

And if it's not too much to ask, what I'd really want is for the user to be able to have 10 or 20 empty rows so they could setup 10 to 20 records at one time then press "SAVE" once and have all of them inserted.