I have overridden the new button on TeamIn__c to display a vf page. This button is on the child related list on the parent (Opportunity)page layout. after clicking it URL is like this.
public class PursuitTeamInformation { public String OppId {get; set;} public Opportunity objOpp {get; set;} public TeamIn__c TeamIn; private Boolean IsAMSCoeSectionVisible; private Boolean IsESICoeSectionVisible; public Boolean IsProject{get; set;} public Boolean IsSF{get; set;} public Boolean IsMoreThanOneRecord{get; set;} private String MoreThanOneRecord = Label.MoreThanOneRecord;
//Constructor public PursuitTeamInformation(ApexPages.StandardController controller) { //Retreive the Opportunity Id from the Url when redirection happens from the //Presale Support Team Information related list this.TeamIn=(TeamIn__c)controller.getRecord(); if(TeamIn.Id == NULL)
// - need to find another way to get the OppID without hardcording a field id in the code
OppId = ApexPages.currentPage().getParameters().get('CF00NP0000000GXwI_lkid'); else { Id TempId = TeamIn.Id; OppId = [Select p.Opportunity__c From TeamIn__c p Where p.Id =: TempId][0].Opportunity__c; } Opportunity tempOpp = [Select o.Id, o.Name, o.StageName, o.Probability, o.Owner.Name, o.Estimated_Amount__c, o.CloseDate, o.Amount, o.Account.Name, o.RecordType.Name From Opportunity o Where o.Id = :OppId][0]; this.objOpp = tempOpp; }
public void CheckRecCount() {
}
public PageReference RedirectToOpportunity() {
//Redirect to Opportunity PageReference objPgRef; objPgRef = new PageReference('/' + this.OppId); objPgRef.setRedirect(true); return objPgRef; }
public Boolean getIsESICoeSectionVisible() { return IsESICoeSectionVisible;
Need your visualforce page also. I wanted to know where were you trying to use parent record Id. I mean in apex:repeat or pageblockTable, etc. So need your visual force.
Without knowing that I can only say, you can use a Inner class with two properties (public String childId{get;set;}, public String parentId{get;set;}) and a constructor. Then you can use that class when you need to get parentId.
public class Outer{
public class Inner{
public String parentId{get;set;}
public String childId{get;set;}
public Inner(){
}
}
}
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Hi,
If you can please post your code.
Hi, here is the class code .
public class PursuitTeamInformation
{
public String OppId {get; set;}
public Opportunity objOpp {get; set;}
public TeamIn__c TeamIn;
private Boolean IsAMSCoeSectionVisible;
private Boolean IsESICoeSectionVisible;
public Boolean IsProject{get; set;}
public Boolean IsSF{get; set;}
public Boolean IsMoreThanOneRecord{get; set;}
private String MoreThanOneRecord = Label.MoreThanOneRecord;
//Constructor
public PursuitTeamInformation(ApexPages.StandardController controller)
{
//Retreive the Opportunity Id from the Url when redirection happens from the
//Presale Support Team Information related list
this.TeamIn=(TeamIn__c)controller.getRecord();
if(TeamIn.Id == NULL)
// - need to find another way to get the OppID without hardcording a field id in the code
OppId = ApexPages.currentPage().getParameters().get('CF00NP0000000GXwI_lkid');
else
{
Id TempId = TeamIn.Id;
OppId = [Select p.Opportunity__c From TeamIn__c p
Where p.Id =: TempId][0].Opportunity__c;
}
Opportunity tempOpp = [Select o.Id,
o.Name,
o.StageName,
o.Probability,
o.Owner.Name,
o.Estimated_Amount__c,
o.CloseDate,
o.Amount,
o.Account.Name,
o.RecordType.Name
From Opportunity o
Where o.Id = :OppId][0];
this.objOpp = tempOpp;
}
public void CheckRecCount()
{
}
public PageReference RedirectToOpportunity()
{
//Redirect to Opportunity
PageReference objPgRef;
objPgRef = new PageReference('/' + this.OppId);
objPgRef.setRedirect(true);
return objPgRef;
}
public Boolean getIsESICoeSectionVisible()
{
return IsESICoeSectionVisible;
}
}
public void SaveValues()
{
if(TeamIn.Id == NULL)
{
insert TeamIn;
}
else
{
update TeamIn;
}
}
public Boolean getIsAMSCoeSectionVisible()
{
return IsAMSCoeSectionVisible;
}
public PageReference Save()
{
PageReference objPgRef;
try
{
SaveValues();
objPgRef = new PageReference('/' + this.OppId);
objPgRef.setRedirect(true);
return objPgRef;
}
catch(DMLException ex)
{
ApexPages.addMessages(ex);
return NULL;
}
}//End save*/
}//End Controller
Hi,
Need your visualforce page also. I wanted to know where were you trying to use parent record Id. I mean in apex:repeat or pageblockTable, etc. So need your visual force.
Without knowing that I can only say, you can use a Inner class with two properties (public String childId{get;set;}, public String parentId{get;set;}) and a constructor. Then you can use that class when you need to get parentId.
public class Outer{
public class Inner{
public String parentId{get;set;}
public String childId{get;set;}
public Inner(){
}
}
}
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
<apex:page standardController="TeamIn__c" extensions="PursuitTeamInformation" action="{!CheckRecCount}" tabstyle="Opportunity" sidebar="true" >
<apex:outputpanel rendered="{!NOT(IsMoreThanOneRecord)}">
<apex:pageBlock title="{!$Label.TeamIn}">
<apex:pageBlock title="{!$Label.Opportunity_Detail}" id="pb_opportunity_detail">
<apex:pageBlockSection id="pbs_opportunity_detail" columns="2">
<apex:outputField value="{!objOpp.ownerid}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.Opportunity.fields.Amount.label}"/>
<apex:outputPanel >
<apex:outputText value="{0, number, $.00}">
<apex:param value="{!objOpp.Amount}" />
</apex:outputText>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$Label.Opportunity_Name}"/>
<apex:outputLink value="/{!objOpp.Id}">{!objOpp.Name}
</apex:outputlink>
</apex:pageBlockSectionItem>
<apex:outputField value="{!objOpp.CloseDate}"/>
<apex:pageBlockSectionItem >
<apex:outputLabel value="{!$ObjectType.Account.fields.Name.label}"/>
<apex:outputLink value="/{!objOpp.Account.id}">{!objOpp.Account.Name}
</apex:outputlink>
</apex:pageBlockSectionItem>
<apex:outputField value="{!objOpp.StageName}"/>
<apex:outputField value="{!objOpp.Probability}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:form >
<apex:pageBlock title="{!$Label.Edit_Presale_Support_Team_Information}">
<apex:pageBlockButtons >
<apex:commandButton value="{!$Label.Save}" action="{!Save}"/>
<apex:commandButton value="{!$Label.Cancel}" action="{!Cancel}"/>
</apex:pageBlockButtons>
<apex:outputpanel id="COEActiveFlagSection">
<apex:pageBlockSection >
<apex:inputField value="{!TeamIn__c.COE_Active_Flag__c}"/>
</apex:pageBlockSection>
</apex:outputpanel><br/>
<apex:outputpanel id="RegionPracticePresalePursuitpanel">
<apex:pageBlockSection title="{!$Label.Region_Practice_Presale_Pursuits}" collapsible="false">
<apex:inputField value="{!TeamIn__c.Region_Practice_Presale_Lead__c}"/>
</apex:pageBlockSection>
</apex:outputpanel><br/>
<apex:outputpanel id="ESICOEPursuitpanel" rendered="{!IsESICoeSectionVisible}">
<apex:pageBlockSection title="{!$Label.ES_I_COE_Presale_Pursuits}" collapsible="false" rendered="{!IsSF}" >
<apex:outputField value="{!TeamIn__c.ES_I_Team_Lead__c}"/>
<apex:inputField value="{!TeamIn__c.ES_I_Presale_Lead__c}"/>
<apex:inputField value="{!TeamIn__c.Support_Cost_Estimated__c}"/>
<apex:inputField value="{!TeamIn__c.Support_Cost_Actual__c}"/>
<apex:inputField value="{!TeamIn__c.Task_Assigned__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="{!$Label.ES_I_COE_Presale_Pursuits}" collapsible="false" rendered="{!IsProject}">
<apex:inputField value="{!TeamIn__c.ES_I_Team_Lead__c}"/>
<apex:inputField value="{!TeamIn__c.ES_I_Presale_Lead__c}"/>
<apex:inputField value="{!TeamIn__c.Support_Cost_Estimated__c}"/>
<apex:inputField value="{!TeamIn__c.Support_Cost_Actual__c}"/>
<apex:inputField value="{!TeamIn__c.Task_Assigned__c}"/>
</apex:pageBlockSection>
</apex:outputpanel><br/>
<apex:outputpanel id="AMSCOEPursuitpanel" rendered="{!IsAMSCoeSectionVisible}">
<apex:pageBlockSection title="{!$Label.AMSCOE_Presale_Pursuits}" collapsible="false">
<apex:inputField value="{!TeamIn__c.AMS_Team_Lead__c }"/>
<apex:inputField value="{!TeamIn__c.AMS_Presale_Lead__c}"/>
<apex:inputField value="{!TeamIn__c.AMS_Support_Cost_Estimated__c}"/>
<apex:inputField value="{!TeamIn__c.AMS_Support_Cost_Actual__c}"/>
</apex:pageBlockSection>
</apex:outputpanel><br/>
<apex:outputpanel id="AdditionalPursuitInformationpanel">
<apex:pageBlockSection title="{!$Label.Additional_Presale_Pursuits_Information}" collapsible="false" >
<apex:inputField value="{!TeamIn__c.Deal_Status__c}"/>
<apex:inputField value="{!TeamIn__c.Comments__c}"/>
<apex:inputField value="{!TeamIn__c.Deal_Value_as_Qualified__c}"/>
<apex:inputField value="{!TeamIn__c.Deal_Value_as_Won__c}"/>
<apex:inputField value="{!TeamIn__c.Deal_Margin_as_Qualified__c}"/>
<apex:inputField value="{!TeamIn__c.Deal_Margin_as_Won__c }"/>
<apex:inputField value="{!TeamIn__c.Cross_Entity_Pursuit__c}"/>
<apex:inputField value="{!TeamIn__c.Other_Fujitsu_Entity__c}"/>
</apex:pageBlockSection>
</apex:outputpanel>
</apex:pageBlock>
</apex:form>
</apex:pageBlock>
</apex:outputpanel>
<apex:outputpanel rendered="{!IsMoreThanOneRecord}" >
<apex:form >
<apex:pageblock >
<apex:pagemessages />
<apex:pageBlockButtons Location="bottom">
<apex:commandButton value="{!$Label.Ok}" action="{!RedirectToOpportunity}"/>
</apex:pageBlockButtons>
</apex:pageblock>
</apex:form>
</apex:outputpanel>
</apex:page>?
Hi, Please suggest .
I am also facing same problem..Please somebody suggest..what to do ..
Thanks
Arup
Hi Arup,
This can be done by following way.
In the URL you already have your parent ID (Opportynity Id ) as a return URL . you can to capture this way
OppId = ApexPages.currentPage().getParameters().get('retURL');
// Using substring function which will return your Opportunity Id .
OppId = OppId.substring(1);
Regards,
gk_myguru
Thanks, can u please give the code for substring method...??