function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
force shahidforce shahid 

Hi Friends, I got error as invalid type an object

Error : Invalid Type : opps__c in Apex code
Here opps is a custom object, i replace this one with standard , but also i get same error invalid type. 
I fetch the data from 3 objects where the name field value is given by me. If i delete the 3rd object i got the result. Why Its not work on 3 objects. 
Plz Help me guys to overcome this problem.

Visual force Page :


<apex:page controller="apmult" >
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title=" Enter the Value">
                <apex:outputText value=" Enter Name "></apex:outputText>
                <apex:inputText value="{!aname}"/>
                <apex:commandButton value=" SUBMIT " action="{!save}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title=" Display Account Records ...{!lac}">
                <apex:pageBlockTable value="{!arecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title=" Display Lead Records ...{!llc}">
                <apex:pageBlockTable value="{!lrecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection title=" Display Oops Records ...{!loc}">
                <apex:pageBlockTable value="{!orecs}" var="item">
                <apex:column value="{!item.id}"/>
                <apex:column value="{!item.name}"/>
                <apex:column value="{!item.phone}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
          </apex:pageBlock>
       </apex:form>
</apex:page>

APEX CODE :

public class apmult {
    public string aname{set;get;}
    public list<account> arecs{set;get;}
    public list<lead> lrecs{set;get;}
    public list<opps__c> orecs{set;get;}
    
    public integer lac{set;get;}
    public integer llc{set;get;}
    public integer loc{set;get;}
    
    public void save(){
        arecs=[select id,name,phone from account where name=:aname];
        
        lac=arecs.size();
        
        lrecs=[select id,name,phone from lead where name=:aname];
        
        llc=lrecs.size();
        
        orecs=[select id,name,phone from account where name=:aname];
        
        loc=orecs.size();
    }

}
Best Answer chosen by force shahid
Mohammad AnzarMohammad Anzar

orecs=[select id,name,phone from account where name=:aname];

in the 3rd object instead of account take opps__c "orecs=[select id,name,phone from opps__c where name=:aname];"

All Answers

Mohammad AnzarMohammad Anzar

orecs=[select id,name,phone from account where name=:aname];

in the 3rd object instead of account take opps__c "orecs=[select id,name,phone from opps__c where name=:aname];"

This was selected as the best answer
sandeep reddy 37sandeep reddy 37
yes mohd is right
force shahidforce shahid
Thank you guys for showing me the error.

But now also i got error , it shows 'opps__c' is not supported. If ur attempting the custom object be sure to append '__c' after entity. i didn't understand . i write opps__c , then y it shows error ?
 
force shahidforce shahid
Problem is solved

Thank you Friends