You need to sign in to do that
Don't have an account?
NSK000
how to get list of records
Hi guys,
please take a look.
I have two objects expenditures and purchase orders(PO). They both have lookup relationship between them. And whenever a PO status is completed, it can't be edited. So whenever we want to edit the existing PO- we need to create another po with in the original po. So the newely created po has POCN__c=1 and original po has POCN__C = 0. Every po has its own expenditure list. Now, I need to display the list of expenditures of POCN__C= 0 on POCN__C = 1. I wrote the following code. I'm not that good at coding. i got the output but whenever i tried to click on the link it says URL no longer exists,,
Apex -
public class ListOfExpenditures
{
public string previousExp{get;set;}
public string currentExp{get;set;}
public List<string> listOfStringName{get;set;}
public ListOfExpenditures(ApexPages.StandardController controller)
{
Id prId = null;
//prId = ApexPages.CurrentPage().getparameters().get('id');
//Purchase_Order__c po=[select Original_Purchase_Order__c from Purchase_Order__c where id='a4R7A000000S7E4'];
Purchase_Order__c po=[select Original_Purchase_Order__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];
id myid=po.Original_Purchase_Order__c;
purchase_order__c po1=[select name,(select id,Name from Expenditures__r) from Purchase_Order__c where id=:myid];
//System.debug(po1.name);
Id expId = null;
List<id> listOfIds;
listOfIds = new List<Id>();
for(Expenditures__c e:po1.Expenditures__r)
{
//System.debug(e.id);
expId = e.id;
listOfIds.add(expId);
}
listOfStringName = new List<string>();
List<Expenditures__c> exp = [select id,Name,Amount__c from Expenditures__c where id in :listOfIds];
for (Expenditures__c el : exp)
{
previousExp = string.valueOf(el.name);
listOfStringName.add(previousExp);
}
}
}
vf -
<apex:page standardcontroller="Purchase_Order__c" extensions="ListOfExpenditures" >
<apex:pageBlock title="List" >
<apex:form >
<apex:outputLink > {!listOfStringName}</apex:outputLink>
</apex:form>
</apex:pageBlock>
</apex:page>
please take a look.
I have two objects expenditures and purchase orders(PO). They both have lookup relationship between them. And whenever a PO status is completed, it can't be edited. So whenever we want to edit the existing PO- we need to create another po with in the original po. So the newely created po has POCN__c=1 and original po has POCN__C = 0. Every po has its own expenditure list. Now, I need to display the list of expenditures of POCN__C= 0 on POCN__C = 1. I wrote the following code. I'm not that good at coding. i got the output but whenever i tried to click on the link it says URL no longer exists,,
Apex -
public class ListOfExpenditures
{
public string previousExp{get;set;}
public string currentExp{get;set;}
public List<string> listOfStringName{get;set;}
public ListOfExpenditures(ApexPages.StandardController controller)
{
Id prId = null;
//prId = ApexPages.CurrentPage().getparameters().get('id');
//Purchase_Order__c po=[select Original_Purchase_Order__c from Purchase_Order__c where id='a4R7A000000S7E4'];
Purchase_Order__c po=[select Original_Purchase_Order__c from Purchase_Order__c where id= :ApexPages.currentPage().getParameters().get('id')];
id myid=po.Original_Purchase_Order__c;
purchase_order__c po1=[select name,(select id,Name from Expenditures__r) from Purchase_Order__c where id=:myid];
//System.debug(po1.name);
Id expId = null;
List<id> listOfIds;
listOfIds = new List<Id>();
for(Expenditures__c e:po1.Expenditures__r)
{
//System.debug(e.id);
expId = e.id;
listOfIds.add(expId);
}
listOfStringName = new List<string>();
List<Expenditures__c> exp = [select id,Name,Amount__c from Expenditures__c where id in :listOfIds];
for (Expenditures__c el : exp)
{
previousExp = string.valueOf(el.name);
listOfStringName.add(previousExp);
}
}
}
vf -
<apex:page standardcontroller="Purchase_Order__c" extensions="ListOfExpenditures" >
<apex:pageBlock title="List" >
<apex:form >
<apex:outputLink > {!listOfStringName}</apex:outputLink>
</apex:form>
</apex:pageBlock>
</apex:page>