You need to sign in to do that
Don't have an account?
Thomas Monson
command link to pass a field to create related item
I have a command link that opens a popup window to create a related record from the opportunity. How can I pass the opportunity into the lookup field on the related item
this is the command button to open the popup
<apex:commandlink styleClass="btn" style="text-decoration:none;padding:4px;" onclick="javascript:void window.open('https://c.na35.visual.force.com/apex/createTest','1478265075053','width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;">New Buying Center</apex:commandLink>
Here is the visualforce page to create the related record
<apex:page standardController="Buying_Center__c" showHeader="false" sidebar="false">
<apex:form >
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>
<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" Value="Save" oncomplete="javascript:CloseAndRefresh()" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Create New Buying Center">
<apex:inputField value="{!Buying_Center__c.opportunity__C}"/>
<apex:inputField value="{!Buying_Center__c.Influence__c}"/>
<apex:inputField value="{!Buying_Center__c.Urgency__c}"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
this is the command button to open the popup
<apex:commandlink styleClass="btn" style="text-decoration:none;padding:4px;" onclick="javascript:void window.open('https://c.na35.visual.force.com/apex/createTest','1478265075053','width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;">New Buying Center</apex:commandLink>
Here is the visualforce page to create the related record
<apex:page standardController="Buying_Center__c" showHeader="false" sidebar="false">
<apex:form >
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
window.top.close();
}
</script>
<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" Value="Save" oncomplete="javascript:CloseAndRefresh()" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Create New Buying Center">
<apex:inputField value="{!Buying_Center__c.opportunity__C}"/>
<apex:inputField value="{!Buying_Center__c.Influence__c}"/>
<apex:inputField value="{!Buying_Center__c.Urgency__c}"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Can you share your VF page code which you are opening the new page. Because it will helps to solve your problem.
Regards,
Yogesh