Skip to main content

Hey everyone! I've been trying to implement this code snippet, but keep running into errors around Apex Identifiers:

 

Error: Compile Error: Invalid identifier '’00Q’'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 6 column 36

 

Error: Compile Error: Invalid identifier '‘Demo'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 7 column 45

 

Error: Compile Error: Invalid identifier '”'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'. at line 17 column 27

Here is the code:

trigger ChangeTheOwnerAndConvert on Event (after insert) {

   Set<Id> LeadIds = new Set<Id>();

   for (Event e: Trigger.new){

   if (e.WhoId != null){

        String eventNameId = e.WhoId;

        if (eventNameId.startsWith(’00Q’) && !String.isBlank(e.Meeting_Type_CP__c)){

            if (e.Meeting_Type_CP__c.equals(‘Demo Request - Standard’)){

                 LeadIds.add(e.WhoId);

                 Lead l = new Lead( Id = e.WhoId);

                 l.OwnerId = e.OwnerId;

                 update l;

                }

          }     

     }

   }

   if(LeadIds.size() > 0){

       Datetime sysTime = System.now();

       sysTime = sysTime.addSeconds(10);

       String chron_exp = ” + sysTime.second() + ‘ ‘ + sysTime.minute() + ‘ ‘ + sysTime.hour() + ‘ ‘ + sysTime.day() + ‘ ‘ + sysTime.month() + ‘ ? ‘ + sysTime.year();

       System.schedule(‘ConvertLead’ + UserInfo.getUserId() +sysTime,chron_exp,new AutoConvertLeads(LeadIds));

   }

}

Does anyone know how to get around this? I'm very new to all of this still and took the code from this article: https://support.chilipiper.com/article/70-convert-lead-to-account-and-auto-create-an-opportunity-upon-booking-meeting

Thank you so much to anyone that can even attempt to help!
3 个回答
  1. 2019年5月13日 02:58
    Use this .. Apex will accept  only single quote for the string 

    and use this code

     

    trigger ChangeTheOwnerAndConvert on Event (after insert) {

    Set<Id> LeadIds = new Set<Id>();

    for (Event e: Trigger.new){

    if (e.WhoId != null){

    String eventNameId = e.WhoId;

    if (eventNameId.startsWith('00Q') && !String.isBlank(e.Meeting_Type_CP__c)){

    if (e.Meeting_Type_CP__c.equals('Demo Request - Standard')){

    LeadIds.add(e.WhoId);

    Lead l = new Lead( Id = e.WhoId);

    l.OwnerId = e.OwnerId;

    update l;

    }

    }

    }

    }

    if(LeadIds.size() > 0){

    Datetime sysTime = System.now();

    sysTime = sysTime.addSeconds(10);

    String chron_exp = ' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();

    System.schedule('ConvertLead' + UserInfo.getUserId() +sysTime,chron_exp,new AutoConvertLeads(LeadIds));

    }

    }

     
0/9000