You need to sign in to do that
Don't have an account?
V Anand
How to print leads in visualforce which follows insertion order.
If displaying leads in visualforce they are not following insertion order.
please anyone help me to print leads in insertion order.
public list<lead> getUnas() {
list<lead> cc=[select created_time__c,id,quemember__c,ownerid,lastname,company,status,email from lead where ownerid=\'00G90000000OTUm\' order by created_time__c];
return cc;
}
The autonumber is guaranteed to be increasing (although not incremental), so I'm surprised that doesn't reflect the order of insertion. Can you tell us a bit more about how you are inserting?
All Answers
why don't you use the standard field CreatedDate?
list<lead> cc=[select created_time__c,id,quemember__c,ownerid,lastname,company,status,email from lead where ownerid=\'00G90000000OTUm\' order by createdDate];
Is this because there are a number of records with the same createdtime?
Its tempting to think that you can just order by id, e.g.
list<lead> cc=[select created_time__c,id,quemember__c,ownerid,lastname,company,status,email from lead where ownerid=\'00G90000000OTUm\' order by id ASC
but I don't think I've seen any docs guaranteeing that the ids will increment/increase with each insert, so I'm not sure whether that would work in all cases. To guarantee ordering you may need to add an autonumber field and order by that.
Are you sure your date in created_time__c is what you want it to be ? Try ordering on the CreatedDate field.
edit: well if this isn't a popular question, 3 replies in a single minute :D
@Sdry
and one of the answers is just the repetion of an other one :P
The only downside with createddate is if you inserted a number of records at once I think you'd lose the order of insertion there as they would have the same createddate value.
And if he wants different createddates but also insert a list he has to use a batch, right bob?
Thank you for your valuable reply...
I created autonumber field on lead and order by that auto number but still it not follows insertion order..
what I can do....
The autonumber is guaranteed to be increasing (although not incremental), so I'm surprised that doesn't reflect the order of insertion. Can you tell us a bit more about how you are inserting?
I am inserting through web-to-lead......
and Its working fine thankyou for your support.