You need to sign in to do that
Don't have an account?
DeepV
SOQL on account fields
Hi,
I'm trying to get the custom field (Hold_ID__c) on to Visualforce page. I am not getting the value in the page.
Passing account id in the url for the page
Here is my VF page:
<apex:page controller="Questionnaire" sidebar="false" showHeader="false">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection columns="1">
<apex:inputText value="{!account}" label="Hold Name"/>
<apex:inputText value="{!holdId}" label="Hold ID"/>
<apex:inputText id="Survey" value="{!txtSurvey}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex code:
public class Questionnaire{
public String holdId { get; set; }
public String txtSurvey { get; set; }
public String account { get; set; }
public Questionnaire() {
account = [SELECT Id, Name,Account.Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
holdId = [SELECT Id, Name, Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Hold_ID__c;
}
public PageReference save() {
Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
aq.Name = txtSurvey;
aq.account__c = apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
}
I'm trying to get the custom field (Hold_ID__c) on to Visualforce page. I am not getting the value in the page.
Passing account id in the url for the page
Here is my VF page:
<apex:page controller="Questionnaire" sidebar="false" showHeader="false">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection columns="1">
<apex:inputText value="{!account}" label="Hold Name"/>
<apex:inputText value="{!holdId}" label="Hold ID"/>
<apex:inputText id="Survey" value="{!txtSurvey}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex code:
public class Questionnaire{
public String holdId { get; set; }
public String txtSurvey { get; set; }
public String account { get; set; }
public Questionnaire() {
account = [SELECT Id, Name,Account.Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Name;
holdId = [SELECT Id, Name, Hold_ID__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')].Hold_ID__c;
}
public PageReference save() {
Audit_Questionnaire__c aq = new Audit_Questionnaire__c();
aq.Name = txtSurvey;
aq.account__c = apexpages.currentpage().getparameters().get('id');
insert aq;
return null;
}
}
Custom field (Hold_ID__c) is hold the value and show in visualforce page.
Output is shown below :-
Passing account id in the url for the page.
Try below code :
Apex code : Visualforce Page : I hope it will help you.
Regards,
Ajay
All Answers
Try this code.
APEX VF Page Let me know if this helps.
Custom field (Hold_ID__c) is hold the value and show in visualforce page.
Output is shown below :-
Passing account id in the url for the page.
Try below code :
Apex code : Visualforce Page : I hope it will help you.
Regards,
Ajay