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
Deb HalderDeb Halder 

Invalid type compile error on trigger

Hello,
I am getting an error Compile Error: Invalid type: Opp_Top_X_Designation__c on the first two lines.

The field Opp_Top_X_Designation__c is a lookup to Opportunity from another object Top_X_Designation. Now either the setup is not correct of the format of the code line is not right. Please provide inputs.

list<Opp_Top_X_Designation__c> oppidlist = new list<Opp_Top_X_Designation__c>();
 list<Opp_Top_Designation__c> updatelist = new list<Opp_Top_Designation__c>();
 
 for(Top_Designation__c tx : trigger.new){
 if(trigger.isUpdate || trigger.isInsert){
  if(tx.Document_Attached__c == true && tx.Typeof__c == 'Contract'){
 
 // mt.put(tx.Opp_Top_X_Designation__c, tx.Id);
 // s.add(tx.Opp_Top_X_Designation__c);
Best Answer chosen by Deb Halder
HARSHIL U PARIKHHARSHIL U PARIKH
I think its because Opp_Top_X_Designation__c  is a field not a object name. You need to put object name in List.

Let's say you have a custom field named Opp_Top_X_Designation__c on opportunity object then you can define a list for an Opportunity such as
List<Opportunity> = New List<Opportunity>();

//This would not work: - List<Opp_Top_X_Designation__c > design = New List<Opp_Top_X_Designation__c>();
If you are trying to collect the values of Opp_Top_X_Designation__c  in one list then make a list of that particular data type.

If Opp_Top_X_Designation__c  is String then make
List<String> str = New List<String>();

For(Opportunity Opp : Trigger.New){
   str.add(Opp.Opp_Top_X_Designation__c); // or whatever your field relationship is.
}

Hope this helps and if it solves the puzzle then please mark it solved!
 

All Answers

RKSalesforceRKSalesforce
Hi Deb,

Looking at the code which you have shared it seems that there should be no problem with the code. It would be really helpful of you share your whole trigger code.

Regards,
Ramakant
HARSHIL U PARIKHHARSHIL U PARIKH
I think its because Opp_Top_X_Designation__c  is a field not a object name. You need to put object name in List.

Let's say you have a custom field named Opp_Top_X_Designation__c on opportunity object then you can define a list for an Opportunity such as
List<Opportunity> = New List<Opportunity>();

//This would not work: - List<Opp_Top_X_Designation__c > design = New List<Opp_Top_X_Designation__c>();
If you are trying to collect the values of Opp_Top_X_Designation__c  in one list then make a list of that particular data type.

If Opp_Top_X_Designation__c  is String then make
List<String> str = New List<String>();

For(Opportunity Opp : Trigger.New){
   str.add(Opp.Opp_Top_X_Designation__c); // or whatever your field relationship is.
}

Hope this helps and if it solves the puzzle then please mark it solved!
 
This was selected as the best answer
Deb HalderDeb Halder
Thanks for your inputs. And @Govind you caught the issue rightaway. This resolved my issue. Thanks!!