You need to sign in to do that
Don't have an account?
MaggieSumit
plz check my code am getting this error : Entity is not org-accessible
public with sharing class contollertest {
Public id Current_le_Id;
public Boolean isEdit { set; get;}
public List<Question__c> lstQuestion {set;get;}
public contollertest (ApexPages.StandardController controller) {
Current_le_Id = controller.getRecord().id;
isEdit = false;
lstQuestion = New List<Question__c>();
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__c)
lstQuestion.add(con);
}
}
public void editProcess(){
isEdit = true;
}
public void save(){
if(lstQuestion.size() > 0){
upsert lstQuestion;
lstQuestion.clear();
}
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__c)
lstQuestion.add(con);
}
isEdit = false;
}
public void addQuestion(){
lstQuestion.add(new Question(leadId = Current_le_Id));
isEdit = true;
}
}
<!--Page-->
<apex:page standardController="Account" extensions="contrllr">
<apex:form >
<apex:pageblock id="pgb">
<apex:pageBlockButtons >
<apex:commandButton value="edit" action="{!editProcess}" rendered="{!Not(isEdit)}" reRender="pgb"/>
<apex:commandButton value="save" action="{!save}" rendered="{!isEdit}" reRender="pgb"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!lstQuestion}" var="val" rendered="{!Not(isEdit)}">
<apex:column value="{!val.Name}"/>
<apex:column value="{!val.Email__c}"/>
</apex:pageBlockTable>
<apex:outputPanel rendered="{!Not(isEdit)}">
<apex:commandButton action="{!addQuestion}" value="Add Contact" reRender="pgb"/>
</apex:outputPanel>
<apex:pageBlockTable value="{!lstQuestion}" var="val" rendered="{!(isEdit)}">
<apex:column headerValue="FirstName">
<apex:inputField value="{!val.Name}"/>
</apex:column>
<apex:column headerValue="Email">
<apex:inputField value="{!val.Email__c}"/>
</apex:column>
<apex:column >
<apex:inputField value="{!val.Email__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
Public id Current_le_Id;
public Boolean isEdit { set; get;}
public List<Question__c> lstQuestion {set;get;}
public contollertest (ApexPages.StandardController controller) {
Current_le_Id = controller.getRecord().id;
isEdit = false;
lstQuestion = New List<Question__c>();
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__c)
lstQuestion.add(con);
}
}
public void editProcess(){
isEdit = true;
}
public void save(){
if(lstQuestion.size() > 0){
upsert lstQuestion;
lstQuestion.clear();
}
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__c)
lstQuestion.add(con);
}
isEdit = false;
}
public void addQuestion(){
lstQuestion.add(new Question(leadId = Current_le_Id));
isEdit = true;
}
}
<!--Page-->
<apex:page standardController="Account" extensions="contrllr">
<apex:form >
<apex:pageblock id="pgb">
<apex:pageBlockButtons >
<apex:commandButton value="edit" action="{!editProcess}" rendered="{!Not(isEdit)}" reRender="pgb"/>
<apex:commandButton value="save" action="{!save}" rendered="{!isEdit}" reRender="pgb"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!lstQuestion}" var="val" rendered="{!Not(isEdit)}">
<apex:column value="{!val.Name}"/>
<apex:column value="{!val.Email__c}"/>
</apex:pageBlockTable>
<apex:outputPanel rendered="{!Not(isEdit)}">
<apex:commandButton action="{!addQuestion}" value="Add Contact" reRender="pgb"/>
</apex:outputPanel>
<apex:pageBlockTable value="{!lstQuestion}" var="val" rendered="{!(isEdit)}">
<apex:column headerValue="FirstName">
<apex:inputField value="{!val.Name}"/>
</apex:column>
<apex:column headerValue="Email">
<apex:inputField value="{!val.Email__c}"/>
</apex:column>
<apex:column >
<apex:inputField value="{!val.Email__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>
</apex:form>
</apex:page>
Hi Sumit,
This is Quite confusing.
First of all I would like to tell you that, You can not Use ID as you have written above. It means you are trying to reference id of Question__c type record but your ID value is of a lead type record (they always starts with 00Q). Hence it is giving you invalid ID value Error.
Now for the other issue. Please go to the fields page of Question__c. Check The API name Of LeadID. use that name as apiname=Current_lead_Id.
this will solve all the issues I guess. Or please share a snapshot of fields of Question__c.
I will be happy to help.
Regards
Abhilash Mishra
All Answers
These type of erorr comes at compile time. It might be possibe you are using some api which does not exist in org or please try to change Api verison of your class and page to higher one.
Here is one more helpful link where simliar question was posted.
http://salesforce.stackexchange.com/questions/4599/efficient-way-to-find-error-causing-save-error-entity-is-not-org-accessible
Thanks
Sandeep Singhal
http://www.codespokes.com/
See the bold line. And use the below code.
public with sharing class contollertest {
Public id Current_le_Id;
public Boolean isEdit { set; get;}
public List<Question__c> lstQuestion {set;get;}
public contollertest (ApexPages.StandardController controller) {
Current_le_Id = controller.getRecord().id;
isEdit = false;
lstQuestion = New List<Question__c>();
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__r) // Use le.Question__r instead of le.Question__c
lstQuestion.add(con);
}
}
public void editProcess(){
isEdit = true;
}
public void save(){
if(lstQuestion.size() > 0){
upsert lstQuestion;
lstQuestion.clear();
}
for(Lead le:[select id,name,(select id,Name,Email__c from Questions__r) from lead where id=:Current_le_Id]){
for(Question__c con:le.Question__c)
lstQuestion.add(con);
}
isEdit = false;
}
public void addQuestion(){
lstQuestion.add(new Question(leadId = Current_le_Id));
isEdit = true;
}
}
Let me know if it helps you out.
When i using a coid for addQuestion its showing that message
public void addQuestion(){
lstQuestion.add(new Question(leadId = Current_le_Id));
isEdit = true;
}
lstQuestion.add
(new Question(leadId = Current_le_Id));replace it with lstQuestion.add(new Question__C(leadId = Current_le_Id));
Regards
Abhilash
and if i use Question then i got error: Entity is not org-accessible.
I think LeadID is also a custom field you made of lookup type for lead. Please Use LeadID__C
Regards
Abhilash
As Abhilash give suggestion that is right but there is little bit mistake that is the field name "
leadId" you need to append "__c" after the field because it is a custom field.If after the appending the "__C" if your code again give error then check the API name of the field leadId in Question__C Object on which you are assigning Current_le_Id.
Thanks.
lstQuestion.add(new Question__c(id = Current_lead_Id));
But when i press AddQuestion Button on VF page i got this error message:
System.TypeException: Invalid id value for this SObject type: 00Q2800000HeVCNEA3
Error is in expression '{!addQuestion}' in component <apex:commandButton> in page jaima: Class.contollertest.addQuestion: line 32, column 1
Class.contollertest.addQuestion: line 32, column 1
Hi Sumit,
This is Quite confusing.
First of all I would like to tell you that, You can not Use ID as you have written above. It means you are trying to reference id of Question__c type record but your ID value is of a lead type record (they always starts with 00Q). Hence it is giving you invalid ID value Error.
Now for the other issue. Please go to the fields page of Question__c. Check The API name Of LeadID. use that name as apiname=Current_lead_Id.
this will solve all the issues I guess. Or please share a snapshot of fields of Question__c.
I will be happy to help.
Regards
Abhilash Mishra