Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Please help to solve List index out of bound :0 pr...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Please help to solve List index out of bound :0 problem
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-09-2012 06:07 AM
Hi,
Please help to resolve the problem if recProfileId is getting null then its showing List index out of bound :0 problem
How can resolve this problem in below code:
public static Integer getRoundingNumber(String recProfileId)
{
List<Supplier_record__C> sp = [select Round_Final_recordt_to__c from Supplier_record__C where id =: recProfileId];
if(sp[0].Round_Final_recordt_to__c!= null && sp.size()>0)
{
Integer round = Integer.valueof(sp[0].Round_Final_recordt_to__c);
system.debug('-----------Round169-----------'+roun
return round ;
}
else
{
return 4;
}
}
Thanks
Chandra
Solved! Go to Solution.
Re: Please help to solve List index out of bound :0 problem
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-09-2012 08:46 AM
Change if condition to..
If(sp.size()>0 && sp[0].Round_Final_Recordt_to__c!=null)
In your code first tou are evaluating sp[0].Round.....__c --> here it will throw error if list size is 0
So you in this case you will have to check for list size first to avoid that error.
Thanks, Saikishore

