You need to sign in to do that
Don't have an account?
How to fill the fields correspondent to Customize Picklist
Hi all,
I have one Custom object CaseType__c which has some custom fields like CaseTypeName, CaseTypeDescription etc and one look up relation of another object Specimen__c which has also some fields like SpecimenName, SpeimentType, SpecimenDescription like that. On VF page I have loaded the CaeTypeName as picklist from CaseTypeObject by ApexCode.
Now my requirment is on the selection of particular CaseTypeName__c, all the fields of Specimen object like SpecimentName, SpecimenType SpecimenDescription should be come. Like If CaseTypeName -ABC has Specimen BCD than on the selection of CaseType-ABC all the fields of Specimen related to BCD record should display on VF page.
This is code but not working ,, please please help, I have ried much but did not get anything
<apex:page controller="ExtentionController"
extensions="CaseTypeExtention">
<apex:form >
<apex:pageblock title="Hello {!$User.FirstName}!" >
<h1>Congratulations</h1>
This is your Accession Page !!<p/>
<apex:pageBlockSection title="Case Information" >
<apex:selectList value="{!objCaseType.CaseTypeName__c }" size="1" multiselect="false">
<apex:actionSupport event="onchange" reRender="details" action="{!readSpecimen}"/>
<apex:selectOptions Value="{!CaseTypeOption }">
</apex:selectOptions>
</apex:selectList>
</apex:pageblocksection>
<apex:pageBlockSection title="Specimen" id="details">
<apex:pageBlockTable value="{!SpecimenList}" var="spec" border="red" width="500%" >
<apex:column value="{!SpecimenList.Name}" width="100%"/>
<apex:column value="{!SpecimenList.SpecimenType__c}" width="100%"/>
</apex:pageBlockTable>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Code
public class CaseTypeExtention
{
public CaseType__c objCaseType {get;set;}
public Specimen__c SpecimenList {get;set;}
//public List<CaseType__c> caseList {get; set;}
public CaseTypeExtention(ExtentionController controller)
{
objCaseType = new CaseType__c();
SpecimenList = new Specimen__c();
// caseList = new List<CaseType__c>();
}
public List<selectOption> CaseTypeOption
{
get
{
List<selectOption> CaseTypeName =new List<selectOption>();
CaseTypeName.add(new selectOption('None', 'None'));
for (CaseType__c cn :[select Name , CaseTypeName__c from CaseType__c])
CaseTypeName.add(new selectOption(cn.Name, cn.CaseTypeName__c));
return CaseTypeName;
}
private set;
}
public PageReference readSpecimen()
{
//caseList = [Select Specimen__c From CaseType__c Where name = '000002' limit 1 ];
//string specimenId = caseList.Specimen__c;
SpecimenList = [select name, SpecimenType__c from Specimen__c where id=:objCaseType.Specimen__c ];
return null;
}
}
Hi Just try this
apex:page controller="ExtentionController"
extensions="CaseTypeExtention">
change this line to
apex:page standardcontroller="CaseType__c"
extensions="CaseTypeExtention">
share the results
Thanks
I tried with this but I am not able to get the record, getting error "List has no rows for assignment to SObject"
than I give the static id like SpecimenList = [select name, SpecimenType__c from Specimen__c where id = 'a0Ae0000006Ih5I']; this is the Specimen id of related casetype,
by this query the record is coming but its static ,, how to get the id of selected Specimen related to case type means in objCaseType. So that we can write wher id = objCaseType.Specimen__c
Hi,
Just try with the following code
public CaseTypeExtention(ExtentionController controller)
{
objCaseType = new CaseType__c();
SpecimenList = new Specimen__c();
// caseList = new List<CaseType__c>();
}
replace this with
public CaseTypeExtention(ExtentionController controller)
{
objCaseType = (CaseType__c)controller.getRecord();
SpecimenList = new Specimen__c();
// caseList = new List<CaseType__c>();
}
keep the rest code same./...
Please mark this soultion as best solution and throw kudos if it helped you.
But now I am not using "public CaseTypeExtention(ExtentionController controller)" , because
apex:page controller="ExtentionController"
extensions="CaseTypeExtention">
change this line to
apex:page standardcontroller="CaseType__c"
extensions="CaseTypeExtention">
so my code is this
public CaseTypeExtention1(ApexPages.StandardController controller) {
1 objCaseType = new CaseType__c();
2 //objCaseType = (CaseType__c)controller.getRecord();
3 SpecimenList = new Specimen__c();
and if I uncomment the line 2, than also the record is not coming same error "List has no rows for assignment to SObject" I have check record is there but this query given problem "[select name, SpecimenType__c from Specimen__c where id =:objCaseType.Specimen__c ];"
in objCaseType.Specimen__c the requird id is not coming
Please please help,,
I knoe that you have done so much
<apex:page Standardcontroller="CaseType__c"
extensions="CaseTypeExtention">
<apex:form >
<apex:pageblock title="Hello {!$User.FirstName}!" >
<h1>Congratulations</h1>
This is your Accession Page !!<p/>
<apex:pageBlockSection title="Case Information" >
<apex:selectList value="{!objCaseType.CaseTypeName__c }" size="1" multiselect="false">
<apex:actionSupport event="onchange" reRender="details" action="{!readSpecimen}"/>
<apex:selectOptions Value="{!CaseTypeOption }">
</apex:selectOptions>
</apex:selectList>
</apex:pageblocksection>
<apex:pageBlockSection title="Specimen" id="details">
<apex:pageBlockTable value="{!SpecimenList}" var="spec" border="red" width="500%" >
<apex:column value="{!SpecimenList.Name}" width="100%"/>
<apex:column value="{!SpecimenList.SpecimenType__c}" width="100%"/>
</apex:pageBlockTable>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Code
public class CaseTypeExtention
{
public CaseType__c objCaseType {get;set;}
public Specimen__c SpecimenList {get;set;}
//public List<CaseType__c> caseList {get; set;}
public CaseTypeExtention(ExtentionController controller)
{
//objCaseType = new CaseType__c();
objCaseType = (CaseType__c)controller.getRecord();
SpecimenList = new Specimen__c();
// caseList = new List<CaseType__c>();
}
public List<selectOption> CaseTypeOption
{
get
{
List<selectOption> CaseTypeName =new List<selectOption>();
CaseTypeName.add(new selectOption('None', 'None'));
for (CaseType__c cn :[select Name , CaseTypeName__c from CaseType__c])
CaseTypeName.add(new selectOption(cn.Name, cn.CaseTypeName__c));
return CaseTypeName;
}
private set;
}
public PageReference readSpecimen()
{
//caseList = [Select Specimen__c From CaseType__c Where name = '000002' limit 1 ];
//string specimenId = caseList.Specimen__c;
SpecimenList = [select name, SpecimenType__c from Specimen__c where id=:objCaseType.Specimen__c ];
return null;
}
}
Just try this..also Selectthe specimen from VF page....
"Method does not exist or incorrect signature: [ExtentionController].getRecord()"
How I can select Specimen from VF page I have to load that on the basis of Casetype, ya Casetype I am already selecting from VF page
public CaseTypeExtention(ExtentionController controller) change this line to
public CaseTypeExtention(ApexPages.Standard controller)
I tried this already but "" List has no rows for assignment to SObject ""
put the system.debug statement just before your query and check what's the value
objCaseType.Specimen__c
than how I will see the value,, I never tried this debug thing
setup-> Monitoring-> debug Logs-> Add your name in it... and in another window open this Vf page and try runnig it.. and go back to debug log click on reset open the log and check the debug statement there...
like if you put System.debug('*************************'+value);
search the **** pattern in your log
No "" reset open the log "" option is there in the Debug Logs
there is alink view and there is a link reset../.