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
Marián ČekanMarián Čekan 

Error: Compile Error: Invalid type

Hi, I'm absolute beginner and I'm trying to get familiar with salesforce triggers. I got main idea - what it's all about but I'm stuck with part of code:

CC_Variables__c variables = CC_Variables__c.getInstance('EloquaMarketingId');

 

I keep getting error: Error: Compile Error: Invalid type: CC_Variables__c at line 9 column 5
 

I have already checked many forums and tried to solve it as follows: "You need to use the API name of the object and not the label. Hence the error. To find the API name of the object go to:

Setup > create> objects> myObject > API name." 

 

But there is not such an object is this the problem? Thank you very much.

 

Best Answer chosen by Marián Čekan
Abhishek BansalAbhishek Bansal
Hi Marian,

Looking at the API name of the custom setting this is a part of one of the package. Please check the sandbox from where you are trying to migrate the changes and install the same package in your sandbox as well. In this way you will get all the components related to that package.
Let me know if you need any more help or information on this. For any immediate help you can reach out to me on:
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790

Thanks,
Abhishek Bansal.

All Answers

David Zhu 🔥David Zhu 🔥
Can you explain why you need to put CC_Variables__c.getInstance('EloquaMarketingId');?
Marián ČekanMarián Čekan

I need to store the data to check whether it is empty. This is my next operation: 

if(variables != null && variables.TextValue__c != null) {
        EloquaMarketingId = variables.TextValue__c; 
    }

{tushar-sharma}{tushar-sharma}
Hi Marian,

Its a custom setting and not custom object. You will find them under custom setting.  You can perform DML operations on them.
https://help.salesforce.com/articleView?id=cs_about.htm&type=5 (https://help.salesforce.com/articleView?id=cs_about.htm&type=5)

​​If this answer helps you, please mark it as accepted.

Regards,
Tushar Sharma
https://newstechnologystuff.com/
mukesh guptamukesh gupta
Hi Marian,

Please use below code:-
 
CC_Variables__c  CC_CS = [SELECT id,TextValue__c FROM CC_Variables__c];
 if(CC_CS.TextValue__c != ''&& CC_CS != null){

//////Add your code/////////////////
}

If this solution is usefull for you, Please mark as a Best Answer to help others.



Regards
Mukesh
Abhishek BansalAbhishek Bansal
Hi Marian,

getInstance method is used for the custom settings. Can you please go to setup -> custom settings -> and make sure that you have any custom setting with the name Variables or not? If yes, than please copy the API name of that custom setting and use this in your code.

Thanks,
Abhishek Bansal.
Marián ČekanMarián Čekan

Hi, Abhishek

I have nothing in here (see in the picture). So is this the problem? To be honest I'm trying to understand and make this code working as a part of exercise to get more into salesforce. So I guess I need to somehow define this custom setting right?

 

Thank you very much

 User-added image

Abhishek BansalAbhishek Bansal
Hi Marian,

Looking at the API name of the custom setting this is a part of one of the package. Please check the sandbox from where you are trying to migrate the changes and install the same package in your sandbox as well. In this way you will get all the components related to that package.
Let me know if you need any more help or information on this. For any immediate help you can reach out to me on:
Gmail: abhibansal2790@gmail.com
Skype: abhishek.bansal2790

Thanks,
Abhishek Bansal.
This was selected as the best answer