You need to sign in to do that
Don't have an account?
Subrahmanyam Konathlapalli
The below code is giving o/p in oneline..... I need the o/p in line by line, I tried but i didn't get....
list<laptop__c> laplist=new list<laptop__c>();
laplist= [select id,name,Harddisk__c,Processor__c from laptop__c];
set<id> recordid=new set<id>();
for (laptop__c lap:laplist){
recordid.add(lap.Harddisk__c);
}
system.debug(recordid);
laplist= [select id,name,Harddisk__c,Processor__c from laptop__c];
set<id> recordid=new set<id>();
for (laptop__c lap:laplist){
recordid.add(lap.Harddisk__c);
}
system.debug(recordid);
Try this for unique:
for (laptop__c lap:laplist){
if(!recordid.contains(lap.Harddisk__c)) {
recordid.add(lap.Harddisk__c);
system.debug(lap.Harddisk__c);
}
}
And let me know if it work for you.
All Answers
better to put debug log inside the for loop:
for (laptop__c lap:laplist){
recordid.add(lap.Harddisk__c);
system.debug(lap.Harddisk__c);
}
Thanks
NKS
Try this for unique:
for (laptop__c lap:laplist){
if(!recordid.contains(lap.Harddisk__c)) {
recordid.add(lap.Harddisk__c);
system.debug(lap.Harddisk__c);
}
}
And let me know if it work for you.
thanks