You need to sign in to do that
Don't have an account?
ANITHA BEEMU 2
need help for having existing addresses
HI all,
i have custom object called locations which is master detail relationship with opportunities,now i want a button (existing location)on the related list of locations in the opportunitypage.i tired below code:
apex code:
public with sharing class ExiLocExtController {
public Opportunity opportunity { get; set; }
public ExiLocExtController() {
String OpportunityId = ApexPages.currentPage().getParameters().get('id');
Opportunity = [SELECT Id, Name, Location__c FROM Opportunity WHERE Id =: OpportunityId];
}
public PageReference save () {
Location__c LOC = new Location__c ( Id = Opportunity.Location__c, Opportunity_Name__c = Opportunity.Id);
try {
Database.update(LOC);
} catch (Exception error) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
}
PageReference page = new PageReference('/' + Opportunity.Id);
return page.setRedirect(true);
}
public PageReference cancel () {
PageReference page = new PageReference('/' + Opportunity.Id);
return page.setRedirect(true);
}
}
visual page:
<apex:page controller="ExiLocExtController">
<apex:form >
<apex:pageblock title="ExistingLocationto test">
<apex:pageMessages />
<apex:pageblockbuttons location="top">
<apex:commandbutton value="save" action="{!save}" />
<apex:commandbutton value="Cancel" action="{!cancel}"/>
</apex:pageblockbuttons>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Opportunity Name</apex:outputLabel>
<apex:outputText >{!Opportunity.Name}</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Location__c</apex:outputLabel>
<apex:inputField value="{!Opportunity.Location__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
i am able to open the page,but that is not saving to the opportunity,kindly help me.
i have custom object called locations which is master detail relationship with opportunities,now i want a button (existing location)on the related list of locations in the opportunitypage.i tired below code:
apex code:
public with sharing class ExiLocExtController {
public Opportunity opportunity { get; set; }
public ExiLocExtController() {
String OpportunityId = ApexPages.currentPage().getParameters().get('id');
Opportunity = [SELECT Id, Name, Location__c FROM Opportunity WHERE Id =: OpportunityId];
}
public PageReference save () {
Location__c LOC = new Location__c ( Id = Opportunity.Location__c, Opportunity_Name__c = Opportunity.Id);
try {
Database.update(LOC);
} catch (Exception error) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage()));
}
PageReference page = new PageReference('/' + Opportunity.Id);
return page.setRedirect(true);
}
public PageReference cancel () {
PageReference page = new PageReference('/' + Opportunity.Id);
return page.setRedirect(true);
}
}
visual page:
<apex:page controller="ExiLocExtController">
<apex:form >
<apex:pageblock title="ExistingLocationto test">
<apex:pageMessages />
<apex:pageblockbuttons location="top">
<apex:commandbutton value="save" action="{!save}" />
<apex:commandbutton value="Cancel" action="{!cancel}"/>
</apex:pageblockbuttons>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Opportunity Name</apex:outputLabel>
<apex:outputText >{!Opportunity.Name}</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Location__c</apex:outputLabel>
<apex:inputField value="{!Opportunity.Location__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
i am able to open the page,but that is not saving to the opportunity,kindly help me.
without this i saved and tried saving the record same not able to save,pLEASE FIND THE DEBUG LOGS
please do help me in this..thank you