You need to sign in to do that
Don't have an account?
Zoom_V
Automating deactivation of User accounts
I am attempting to automate the deactivation of User accounts for terminated employees. In order to streamline the process I am attempting to use Email Services to kick off some code which will look up an account and mark it deactivated upon receiving an email with "Termination" in the subject and the employee ID in the body.
Here is some code I have which I cannot get to work :
I can't get the controller to save properly. I continuously get an error : "expecting left curly bracket, found '(' at line 1 column 32 "
Any ideas on this ?
Thank you.
Here is some code I have which I cannot get to work :
global class InboundEmailHandler implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) { if ( email.subject == 'Termination' ) { TerminateController.getInstance().terminate(email.plainTextBody); } return result; } }
public class TerminateController() { @TestVisible private static final TerminateController INSTANCE = new TerminateController(); public static TerminateController getInstance() { return INSTANCE; } public void terminate(String commaSeparatedString) { String[] employeeids = commaSeparatedString.split(','); List<User> users = [SELECT isActive FROM User WHERE employee_Id__c IN: employeeids and isActive = true]; for ( User u : users ) { u.isActive = false; } update users; }
I can't get the controller to save properly. I continuously get an error : "expecting left curly bracket, found '(' at line 1 column 32 "
Any ideas on this ?
Thank you.
More info on implementing the InboundEmailHandler can be found here: https://developer.salesforce.com/page/An_Introduction_To_Email_Services_on_Force.com
And information on the various methods and variables of the InboundEmailResult class can be found here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_inbound_result.htm
All Answers
The issue is in the very first line of your Controller class. Remove the () after TerminateController and you should be good to go.
More info on implementing the InboundEmailHandler can be found here: https://developer.salesforce.com/page/An_Introduction_To_Email_Services_on_Force.com
And information on the various methods and variables of the InboundEmailResult class can be found here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_inbound_result.htm