You need to sign in to do that
Don't have an account?

Issue with class and Visualforce page
I am trying to pull the AccountID from Healthcloud, and display it on a visualforce page and receiving visualforce error : List index out of bounds: 0
An unexpected error has occurred. Your development organization has been notified.
Here is my class:
public with sharing class PatientAccountController {
public String accountId{get;set;}
public String accountrelatedlist{get;set;}
public PatientAccountController(){
String cId = apexpages.currentPage().getParameters().get('recId');
accountrelatedlist = apexpages.currentPage().getParameters().get('relatedlist');
List<Contact> accID = [Select id, AccountId From Contact where Id = :cid Limit 10];
accountId = accId[0].AccountId;
}
}
Here is my visualforce page:
<apex:page controller="PatientAccountController" > docType="html-5.0" showHeader="false sidebar="false" applyHtmlTag="false" applyBodyTag="false" standardStylesheets="true"
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<style>
html,
body{
height:100%;
width:100%;
background:#FFFFFF;
font-family:ProximaNovaRegular, Arial, sans-serif;
</style>
</head>
<body>
<iframe id="Ifrmaccountlistview" src="/apex/DE_All_EMR_Data?id={!accountId}" width="100%" height="640px" scrolling="true" frameborder="false"></iframe>
</body>
</html>
</apex:page>
I have verified that there are active accounts in the org, Healthcloud is enabled, can someone explain why I am getting the error?
An unexpected error has occurred. Your development organization has been notified.
Here is my class:
public with sharing class PatientAccountController {
public String accountId{get;set;}
public String accountrelatedlist{get;set;}
public PatientAccountController(){
String cId = apexpages.currentPage().getParameters().get('recId');
accountrelatedlist = apexpages.currentPage().getParameters().get('relatedlist');
List<Contact> accID = [Select id, AccountId From Contact where Id = :cid Limit 10];
accountId = accId[0].AccountId;
}
}
Here is my visualforce page:
<apex:page controller="PatientAccountController" > docType="html-5.0" showHeader="false sidebar="false" applyHtmlTag="false" applyBodyTag="false" standardStylesheets="true"
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<style>
html,
body{
height:100%;
width:100%;
background:#FFFFFF;
font-family:ProximaNovaRegular, Arial, sans-serif;
</style>
</head>
<body>
<iframe id="Ifrmaccountlistview" src="/apex/DE_All_EMR_Data?id={!accountId}" width="100%" height="640px" scrolling="true" frameborder="false"></iframe>
</body>
</html>
</apex:page>
I have verified that there are active accounts in the org, Healthcloud is enabled, can someone explain why I am getting the error?
replace your class with this class and let me know if it doesnt work.
Devanshu
All Answers
replace your class with this class and let me know if it doesnt work.
Devanshu
Your code is working fine.
Have you placed the contact record id in the visual force page URL ?
Like this :
https://c.ap2.visual.force.com/apex/PatientController?recId=0012800000l1Ptx
Regards,
Mukesh
List index out of bounds: 0
An unexpected error has occurred. Your development organization has been notified.
It is working in my org..just ensure that you passing ID to url like mukesh said
https://c.ap2.visual.force.com/apex/PatientController?Id=0042800000l1Pdfx
Thank you for the help!
Thanks for your confirmation.
Keep learning!!!
Thanks,
Mukesh