You need to sign in to do that
Don't have an account?
Hari nadh babu Eluru 7
Records between Min and Max of age field
If user enter min age, max age . fetch all the students in between that min and max age
- in above example try to load students in ascending order based on age
Please find the below VF page and Apex class for that. I have used the Contact object just replace the object name and fields what ever you need.
VF page:
Apex Class
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
You are looking for search functionality ? . If so please help the community what sort of code you are expecting. Is it using Visualforce page, Aura or LWC?
Thanks,
Please find the below VF page and Apex class for that. I have used the Contact object just replace the object name and fields what ever you need.
VF page:
Apex Class
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Here is the Solution to get the record between Min and Max age.
VisualForce Page:
<apex:page Controller="StudentMinMaxAge" >
<apex:form > <apex:pageBlock title="Student Age">
<apex:pageBlockSection columns="1">
Min Age<apex:inputText value="{!minage}"/>
Max Age<apex:inputText value="{!maxage}"/>
</apex:pageBlockSection> <apex:pageBlockButtons >
<apex:commandButton action="{!search}" value="Search"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!studentObj}" var="c">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.minAge__c}"/>
<apex:column value="{!c.maxAge__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class StudentMinMaxAge {
public integer maxage{get;set;}
public integer minage{get;set;}
public List <Student__c> studentObj {get;set;}
public void search(){
studentObj = new list<Student__c>();
studentObj=[select Name, minAge__c,maxAge__c from Student__c where minAge__c>=:minage AND maxAge__c<=:maxage ORDER BY minAge__c ASC];// you can sort the data in ascending order by minAge__c or maxAge__c.
system.debug('studentObj'+studentObj);
}
}
Hope you find your solution.
Thanks and Regards.
https://checkthenbuy.com
https://www.10bestkeyboards.com