You need to sign in to do that
Don't have an account?

VF Component unknown property 'string.Name'
I am writing an controller and VF component to email opportunitylineitemschedule details as an attachment. I am able to include schedule details to the attachment, but i am not able to include the opportunitylineitem's field in the same table.
My requirement - for each line item schedule row, i would like to have one column populating the opportunitylineitem.Product_Name__c values. I am getting unknown property error 'String.Product_Name__c' if i try to add this field.
my controller:
public class emailtemplatev2{
public emailtemplatev2() {
}
List<OpportunityLineItemSchedule> revenue = new List<OpportunityLineItemSchedule>();
public Id opportunityId {get;set;}
public List<OpportunityLineItemSchedule> getrevenue()
{
revenue=[Select OpportunityLineItemId, CurrencyIsoCode, ScheduleDate,Revenue
from OpportunityLineItemSchedule where OpportunityLineItemId IN (Select ID from OpportunityLineItem
where OpportunityId =:opportunityid ) ];
return revenue;
}
}
VF Component:
<apex:component controller="emailtemplatev2" access="global">
<apex:attribute name="AcctId" type="Id" description="Id of the account" assignTo="{!opportunityId}"/>
<table border = "2" cellspacing = "0" >
<tr>
<td>Product</td>
<td>Forecast Period</td>
<td>Currency</td>
<td>Amount</td>
</tr>
<apex:repeat value="{!revenue}" var="o">
<tr>
<td>{!o.OpportunityLineItemId.Product_Name__c}</td> //having issue in this line
<td>
<apex:outputText value="{0,date,MMM, yyyy}">
<apex:param value="{!o.ScheduleDate}" />
</apex:outputText>
</td>
<td>{!o.CurrencyIsoCode}</td>
<td>{!o.Revenue}</td>
</tr>
</apex:repeat>
</table>
</apex:component>
My requirement - for each line item schedule row, i would like to have one column populating the opportunitylineitem.Product_Name__c values. I am getting unknown property error 'String.Product_Name__c' if i try to add this field.
my controller:
public class emailtemplatev2{
public emailtemplatev2() {
}
List<OpportunityLineItemSchedule> revenue = new List<OpportunityLineItemSchedule>();
public Id opportunityId {get;set;}
public List<OpportunityLineItemSchedule> getrevenue()
{
revenue=[Select OpportunityLineItemId, CurrencyIsoCode, ScheduleDate,Revenue
from OpportunityLineItemSchedule where OpportunityLineItemId IN (Select ID from OpportunityLineItem
where OpportunityId =:opportunityid ) ];
return revenue;
}
}
VF Component:
<apex:component controller="emailtemplatev2" access="global">
<apex:attribute name="AcctId" type="Id" description="Id of the account" assignTo="{!opportunityId}"/>
<table border = "2" cellspacing = "0" >
<tr>
<td>Product</td>
<td>Forecast Period</td>
<td>Currency</td>
<td>Amount</td>
</tr>
<apex:repeat value="{!revenue}" var="o">
<tr>
<td>{!o.OpportunityLineItemId.Product_Name__c}</td> //having issue in this line
<td>
<apex:outputText value="{0,date,MMM, yyyy}">
<apex:param value="{!o.ScheduleDate}" />
</apex:outputText>
</td>
<td>{!o.CurrencyIsoCode}</td>
<td>{!o.Revenue}</td>
</tr>
</apex:repeat>
</table>
</apex:component>
"{!o.OpportunityLineItemId}" - a string because this variable represents id of the record. If you want to get the related field on OpportunityLineItem, you need query this field in the controller and use relation like that "{!o.OpportunityLineItem.Product_Name__c}".
If it helped you, then please select it the best answers it will help outer also.
Thanks,
Alex
All Answers
"{!o.OpportunityLineItemId}" - a string because this variable represents id of the record. If you want to get the related field on OpportunityLineItem, you need query this field in the controller and use relation like that "{!o.OpportunityLineItem.Product_Name__c}".
If it helped you, then please select it the best answers it will help outer also.
Thanks,
Alex
If i add OpportunityLineItemId.Product_Name__c in the querry - i am getting relationship error. can you advise how to include this field in the querry?
revenue=[Select OpportunityLineItemId.ProductName__c, CurrencyIsoCode, ScheduleDate,Revenue
from OpportunityLineItemSchedule where OpportunityLineItemId IN (Select ID from OpportunityLineItem
where OpportunityId =:opportunityid ) ];
return revenue;
Thanks,
Alex