• Michael Foster 5
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I am unable to save the code in the above trailhead lesson. I get a Problem, Unexpected Token '01'. I am having a tough time finding a solution and surprised given its in a trailhead...
01public class EmailMissionSpecialist {
02 
03   // Public method
04   public void sendMail(String address, String subject, String body) {
05      // Create an email message object
06      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
07      String[] toAddresses = new String[] {address};
08      mail.setToAddresses(toAddresses);
09      mail.setSubject(subject);
10      mail.setPlainTextBody(body);
11      // Pass this email message to the built-in sendEmail method
12      // of the Messaging class
13      Messaging.SendEmailResult[] results = Messaging.sendEmail(
14                                new Messaging.SingleEmailMessage[] { mail });
15       
16      // Call a helper method to inspect the returned results
17      inspectResults(results);
18   }
19 
20   // Helper method
21   private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
22      Boolean sendResult = true;
23      // sendEmail returns an array of result objects.
24      // Iterate through the list to inspect results.
25      // In this class, the methods send only one email,
26      // so we should have only one result.
27      for (Messaging.SendEmailResult res : results) {
28         if (res.isSuccess()) {
29            System.debug('Email sent successfully');
30         }
31         else {
32            sendResult = false;
33            System.debug('The following errors occurred: ' + res.getErrors());                 
34         }
35      }
36      return sendResult;
37   }
38 
39}
Invoking Lead Assignment Rule From Apex Code

I am not having success. Can anyone help. I am an admin. Not a developer. New to APEX. I am running a app with an Apex Class Email Processor. Do I plug the code in the existing Apex Class Email Processor or create a new Apex Class? Do I use an existing or create a Visual Force page? Other? I tried adding to existing and the assignment rule is not working. I tried creating a new Apex Class, the code as is is not accepted. I also created a Visual Force page and the rule does not trigger. 

//Fetching the assignment rules on case
02AssignmentRule AR = new AssignmentRule();
03AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
04 
05//Creating the DMLOptions for "Assign using active assignment rules" checkbox
06Database.DMLOptions dmlOpts = new Database.DMLOptions();
07dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
08 
09Case newCase = new Case(Status = 'New') ;
10//Setting the DMLOption on Case instance
11newCase.setOptions(dmlOpts);
12insert newCase ;
Hi Team,

I am trying to create a validation Rule i have custom Field called status it has 4 picklist values(NEW,old,current,upgraded) when any one of the value is selected user shou;ld not be able to edit the Fields.


AND(
    ISPICKVAL( status__c,'NEW'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c )
)
    ISPICKVAL( status__c,'old'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    )
    ISPICKVAL( status__c,'current'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
    ISPICKVAL( status__c,'upgraded'),
    OR(
        ISCHANGED( NHPMS__Re_Admit__c ),
        ISCHANGED( NHPMS__Discharge_Date__c ),
        ISCHANGED( Next_Appointment__c ))
    
)
)
how to report/query the recipients of email alerts
Invoking Lead Assignment Rule From Apex Code

I am not having success. Can anyone help. I am an admin. Not a developer. New to APEX. I am running a app with an Apex Class Email Processor. Do I plug the code in the existing Apex Class Email Processor or create a new Apex Class? Do I use an existing or create a Visual Force page? Other? I tried adding to existing and the assignment rule is not working. I tried creating a new Apex Class, the code as is is not accepted. I also created a Visual Force page and the rule does not trigger. 

//Fetching the assignment rules on case
02AssignmentRule AR = new AssignmentRule();
03AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
04 
05//Creating the DMLOptions for "Assign using active assignment rules" checkbox
06Database.DMLOptions dmlOpts = new Database.DMLOptions();
07dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
08 
09Case newCase = new Case(Status = 'New') ;
10//Setting the DMLOption on Case instance
11newCase.setOptions(dmlOpts);
12insert newCase ;

In one of my Sandbox ORG's, I've my IP range added, and I am able to login to the website, but the Force.com IDE simply won't allow me in...keeps telling me that my credentials are wrong.

Any help will be much appreciated.

Thanks.