I have custom object called offering_details__C which lookup to question .
visualforce page for question with saved in the custom object and list all the question in the same page . Below is the code. am facing problem with zone in the question .. How to get id of the custom object in the visualforce.
<apex:page showHeader="true" sidebar="true" standardController="question" extensions="iNeedChatterAnswers">
<apex:form >
<apex:pageBlock title="Question information" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton action="{!saveMethod}" value="Save"/>
<apex:commandButton action="{!Cancel}" value="Cancel"/>
<apex:commandButton Id="btnSearch" action="{!search}" rerender="renderBlock" status="status" title="Search" value="Search"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Question page" columns="2">
<apex:inputtext id="searchTextBox" value="{!searchText}"/>
<apex:inputField value="{!questionData.Title}"/><br/>
<apex:inputField value="{!questionData.Body}"/>
<!--<apex:inputField value="{!questionData.Community}"/-->
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller code:
public with sharing class iNeedChatterAnswers {
Public Question questionData {get;set;}
public Offering_Details__c offeringData {get;set;}
Id offeringId;
public iNeedChatterAnswers(ApexPages.StandardController controller) {
Id offeringId = ApexPages.CurrentPage().getParameters().get('id');
if(offeringId == null)
offeringId = 'a1HS0000001dCMM';
questionData = (Question)controller.getRecord();
// offeringData =[]
}
public PageReference saveMethod (){
questionData.Question_title__c = offeringId;
questionData.CommunityId ='09aS0000000CdTuIAK';
insert questionData;
return null;
//PageReference myPage = Page.
}
}