You need to sign in to do that
Don't have an account?
zingo15607997408952558059
Need help with custom sort options
I am new to apex, and have little java experience.
I am trying to setup a custom sort method for a custom object support__C
I would like to be able to first sort by a custom field titled Closed__c (this field allows a default value of checked or unchecked in a check box) more specifically... I would like to have the custom fields default value unchecked be listed first and checked to be below.
Then I would like to add a method that sorts both checked and unchecked lists by the date created.
The idea: if a topic is unchecked it is not closed, I want it at the top, but I also then want to sort all unchecked by date created.
then repeat the same for default value checked which would mean closed.
I am trying to setup a custom sort method for a custom object support__C
I would like to be able to first sort by a custom field titled Closed__c (this field allows a default value of checked or unchecked in a check box) more specifically... I would like to have the custom fields default value unchecked be listed first and checked to be below.
Then I would like to add a method that sorts both checked and unchecked lists by the date created.
The idea: if a topic is unchecked it is not closed, I want it at the top, but I also then want to sort all unchecked by date created.
then repeat the same for default value checked which would mean closed.
You can use order by in SOQL, first you have to add Closed__c and then CreatedDate then the value will come defult in order.
If you have given only very top level requiremnt. If you need more help please let me know.
Regards | Atul
Do you need to display the sorted result based on all those criteria or you want to sort after the result is shown?
I think this will solve your problem.
You could do your query like this:
[SELECT id, nam, closed__c from support__c where closed__c != null order by closed__c];
//you can put asc at the end then it will show you the closed__c = false first and if you do it desc then it will show you the closed__c = true first;
[SELECT id, nam, closed__c from support__c where closed__c != null order by closed__c asc/desc];
Let me know if that is what you wanted.
Thanks,
justin~sfdc