You need to sign in to do that
Don't have an account?
Dhanya N
SOQL doesn't return results in the order of list which is used IN: clause
Hi All,
List<Id> pricebookEntryIdList = new List<Id>().
Here I have record ids in the list pricebookEntryIdList which is in the order I want.
List<PricebookEntry> products = [SELECT Id, Product2.Name, Product2.ProductCode, Product2.recordtypeid, Product2.recordtype.name FROM PricebookEntry WHERE Id IN :pricebookEntryIdList]
Above query doesn't return the record details in the same order of pricebookEntryIdList list.
For example : If pricebookEntryIdList contains {def, abc, ghi}, products contains records in the order of {abc, def, ghi}
Please help me to solve this.
Thanks,
Dhanya
List<Id> pricebookEntryIdList = new List<Id>().
Here I have record ids in the list pricebookEntryIdList which is in the order I want.
List<PricebookEntry> products = [SELECT Id, Product2.Name, Product2.ProductCode, Product2.recordtypeid, Product2.recordtype.name FROM PricebookEntry WHERE Id IN :pricebookEntryIdList]
Above query doesn't return the record details in the same order of pricebookEntryIdList list.
For example : If pricebookEntryIdList contains {def, abc, ghi}, products contains records in the order of {abc, def, ghi}
Please help me to solve this.
Thanks,
Dhanya
I want records to be in the order of pricebookEntryIdList in which I already have Ids in ther order which I want. So ORDER BY Id will not help me here.
Thanks,
Dhanya
Please check once below sample code, But this is not a best practice.
Above code will work base on record id order it will display records.
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com