You need to sign in to do that
Don't have an account?
vijendhar k 23
Random list of ID's Generation
Hello all,
How to generate random list of ID's from existed list.
example : i have 1000 records in list. in that i have to generate 10 random records. and the 10 random records must be unique
how to achive this functionallity using APEX.
Its bit urgent requirement . your help is appreciable.
Thanks
Vijay
How to generate random list of ID's from existed list.
example : i have 1000 records in list. in that i have to generate 10 random records. and the 10 random records must be unique
how to achive this functionallity using APEX.
Its bit urgent requirement . your help is appreciable.
Thanks
Vijay
please try the below logic if it work for you.
For(i=0;i<10;i++)
{
static Random rnd = new Random();
int r = rnd.Next(yourlist.Count);
if(newlist.contains(yourlist.get(r))){
i--;
}else{
newlist.add(yourlist.get(r));
}
}