Hello I want to relate a custom object to OpportunityLineItem but OpportunityLineItem cannot have a lookup field pointing to it. I have a custom text field referencing the OpportunityLineItem Id - I want to use this to display the new child object in the OpportunityLineItem page(s).
I can get the id for the Custom Obj, but I don't know how to display this object, page or its fields in a visualforce page. Class:
public class LeafGrabber {
public OpportunityLineItem record {get;set;}
public ApexPages.StandardController sc;
public string OLIid {get;set;}
public string LeafId {get;set;}
public LeafGrabber(ApexPages.StandardController controller) {
record = (OpportunityLineItem)controller.getRecord();
sc = controller;
OLIid=record.id;
LeafId = [select id from CUstom_obj__c where ProductId__c =: OLIid Limit 1].id;
}
public PageReference ShowLeaf (){
PageReference LeafUrl = new PageReference('/'+LeafId );
return LeafUrl;
}
}
Page
<apex:page standardController="OpportunityLineItem" title="LeafOnLineItem" extensions="leafgrabber">
<apex:outputField value="{!OpportunityLineItem.id}" rendered="true"/>
{!LeafId}
</apex:page>