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
Tal TsrorTal Tsror 

Error: Compile Error: Invalid type - what am i missing

I saw TONS of errors like this in the web, most of them are related to double underscore (__).
I double and triple checked and i have no idea what am i missing, will appreicate if someone can assist.

Obviously, the API name of these fields are similiar - Can someone please point me what am I missing? 

Edit | Del Internal SummaryInternal_Summary__c Long Text Area(32768)  Tal Tsror, 10/6/2016 12:03 PM
Edit | Del Internal Summary HistoryInternal_Summary_History__c Long Text Area(32768)  Tal Tsror, 10/10/2016 3:41 PM

error
Best Answer chosen by Tal Tsror
Apoorv Saxena 4Apoorv Saxena 4
Modify your code to the following and pass Zendesk Ticket as a paramater to the method:
 
public class internalSummaryClass{     
    public static void applyToHistory(Zendesk_Ticket__c[] currentSummary)
    {
        for(Zendesk_Ticket__c i:currentSummary)    {
            i.Internal_Summary_History__c = i.Internal_Summary__c + i.Internal_Summary_History__c ;     
​    } 
}

Let me know if this helps!

Thanks,
Apoorv

All Answers

Apoorv Saxena 4Apoorv Saxena 4
Hi Tal,

You need to use field name with object reference. Please try the below code:

 
public class internalSummaryClass{
    public static void applyToHistory(Internal_Summary__c[] currentSummary){
        currentSummary.Internal_Summary_History__c = currentSummary.Internal_Summary__c + currentSummary.Internal_Summary_History__c ;
    }
}

Please mark this question as solved if this helps you so that others can view it as a proper solution.

Thanks,
Apoorv
Preya VaishnaviPreya Vaishnavi

what do you want to do here?
Tal TsrorTal Tsror
Hi there, thanks for the prompt response! I'll check though the error message is on line 2 column 38.
Tal TsrorTal Tsror
Use case is simple - I have 2 custom fields "Internal Summary" and "Internal Summary History".
I want to concat the Internal summary to the history field (including timestamp of the update), so we'll be able to see all updates on ticket.

Just to mention the object is custom one from Zendesk tickets, not sure if it is important to mention :)
Tal TsrorTal Tsror
Like i suspected - It is not the issue have a look
Apoorv Saxena 4Apoorv Saxena 4
Hi Tal,

As you are accepting array of Internal_Summary__c as arguements to the method, please modify the code as follows:
 
public class internalSummaryClass{     
    public static void applyToHistory(Internal_Summary__c[] currentSummary)
    {
        for(Internal_Summary__c i:currentSummary)    {
            i.Internal_Summary_History__c = i.Internal_Summary__c + i.Internal_Summary_History__c ;     
​    } 
}


Please mark this question as solved if this helps you so that others can view it as a proper solution.

Thanks,
Apoorv
Tal TsrorTal Tsror
Actually - this is not an array, just single field. I'll remove the brackets, however, it still does not work.
sridharbsridharb
Hello Tal,

If I understand correctly Internal_Summary__c is  a filed not an Object, hence the error so obivous. In method definition at Line 2, Refer the name of the Object in which this (Internal_Summary__c) filed being defined not the feild name unless your Object API is also same as filed name.

Check Object permissions.
 
Apoorv Saxena 4Apoorv Saxena 4
Oops, I thought Internal_Summary__c to be an Sobject type, yes then you are right you cannot pass a field an a parameter to method.
It should either be a primitive data type, or SObject Type.

Hope this helps.
Tal TsrorTal Tsror
Sridhar you are right. Internal_Summary__c is a field, not Object (object is Zendesk Ticket). Can you give more details what i should write then? Sorry for dummy questions, this is my first APEX class...
Apoorv Saxena 4Apoorv Saxena 4
Modify your code to the following and pass Zendesk Ticket as a paramater to the method:
 
public class internalSummaryClass{     
    public static void applyToHistory(Zendesk_Ticket__c[] currentSummary)
    {
        for(Zendesk_Ticket__c i:currentSummary)    {
            i.Internal_Summary_History__c = i.Internal_Summary__c + i.Internal_Summary_History__c ;     
​    } 
}

Let me know if this helps!

Thanks,
Apoorv
This was selected as the best answer
Tal TsrorTal Tsror
I have two custom fields (in zendesk ticket object) - 
Internal_Summary__c and Internal_Summary_History__c 

I want to copy the data from internal_summary to the history, and add timestamp - This should be with trigger everytime the internal summary is modified.

can you guide me how? 
Tal TsrorTal Tsror
OK - i did the following, managed to save it :) good progress :)
 
public class internalSummaryClass{
    public static void applyToHistory(Zendesk__Zendesk_Ticket__c currentTicket){
        currentTicket.Internal_Summary_History__c = currentTicket.Internal_Summary__c + currentTicket.Internal_Summary_History__c ;
    }
}
How can i trigger it to be on modification?
Apoorv Saxena 4Apoorv Saxena 4
Try this code:
 
trigger updateInternalSummaryHistory on Zendesk_Ticket__c(before insert,before update){
	for(Zendesk_Ticket__c z:trigger.new){
		z.Internal_Summary_History__c = z.Internal_Summary__c + z.Internal_Summary_History__c ;
	}
}

Let me know if this works!

Thanks,
Apoorv
Tal TsrorTal Tsror
Hmm - yeah, was thinking the same but i don't have "NEW" in APEX Trigger. I'll play around with it a bit.

Thank you for your help!!!!
Apoorv Saxena 4Apoorv Saxena 4
Rather than creating Apex Class, create an Apex Trigger and paste the code I provided above and activate the trigger.
Now test and verify the functionality.

Or Why even bother about writing code, you can do it through workflow rules as well.

For Apex Trigger . Go to -> Developer Console , Click File -> New -> Apex Trigger.


Please mark this question as solved if this helps you so that others can view it as a proper solution.

Thanks,
Apoorv
Tal TsrorTal Tsror
Wow! super complicated :) a lot to learn.
I can see it now, so i'll test tomorrow and keep you posted!
sridharbsridharb
Hi Tal,

Thats great to know. Its normal be confused when trying things for first time. I wish you good luck.

its a good a practice to encourage the community, acknowledge the best answer when you find the solution for the question.

Regards
Sri
Tal TsrorTal Tsror
great i'll do this as well! can you please quickly reply with how i add current timestamp? I would like to add to my function above timestamp of the addition.
sridharbsridharb
Use System.now  for datetime
Tal TsrorTal Tsror
great Sridhar! will let you know how it goes. thank you very much for support and assitance.
Tal TsrorTal Tsror
Rrrr too bad. The specific "internal summary" field in arriving from Zendesk. Now, i see i don't have any cases in the sandbox (which i created today for the APX) so i need to configure yet another integration. BUHH.

Is there any chance to move Apex class and trigger to production under my responsibility? I'm willing to take the risk as i'm SFDC + Zendesk Admin.
Apoorv Saxena 4Apoorv Saxena 4
Hi Tal,

Yes, you can create an 'Outbound Change Set' in your Sandbox, and add all the components you wish to deploy to production and then deploy them. Then log in to Production org and you can find the change set under 'Inbound Change Set', click on the change set you wish to deploy and click 'Deploy'.

For more info on how to move components from Sanbox to Production, refer to this link : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_deploy.htm

Hope this helps !
Tal TsrorTal Tsror
hey guys,

going forward with this - i have two more questions:

1. If i upload config set to production - will i have a way to delete it? or it is a one-way ticket?

2. I'm getting the following error, though i'm admin - what am i missing? 

User-added image
Tal TsrorTal Tsror
OK found the answer for (2) with quick google search. need answer on (1).
Tal TsrorTal Tsror
Hello team! How are you?

So, good news, i was able to create and upload the trigger to the production! It was hell of a job as I needed to create new sandbox of partial data, to have the Zendesk Tickets (custom object) raw data included in the migration.

Now, i'm trying to validate it before, but getting the following error - what should i do to solve this? 

User-added image

BTW, i deleted the class i wrote as I just realized i'm not even using it. So the trigger works on the data in sandbox.
Rohit Gajbhiye 7Rohit Gajbhiye 7
Please give me the solution I'm the beginner levelplease give me the solution I'm the beginner level