You need to sign in to do that
Don't have an account?
Lorr Mc
future class not working
Hi,
I am completely new to Apex Classes and have been trying the following with little joy.
I have a flow that should create a user however due to mixed DML error I have found that I need to create a future method class.
My flow should fire when picklist value changes to Approved.
Do I need to reference the flow below as I am not getting any errors when I save the class.
public class Util {
@future
public static void insertUserWithRole(
String uname, String al, String em, String lname) {
Profile p = [SELECT Id FROM Profile WHERE Name='Profile_ID__c'];
UserRole r = [SELECT Id FROM UserRole WHERE Name='Role_Id__c'];
// Create new user with a non-null user role ID
User u = new User(alias = 'New_Acquisition_Alias', email='New_Acquisition_User_Email__c',
emailencodingkey='UTF-8', lastname='New_Acquisition_User_Last_Name__c',
languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, userroleid = r.Id,
timezonesidkey='Europe/London',
username='Europe/London');
insert u;
}
}
I am completely new to Apex Classes and have been trying the following with little joy.
I have a flow that should create a user however due to mixed DML error I have found that I need to create a future method class.
My flow should fire when picklist value changes to Approved.
Do I need to reference the flow below as I am not getting any errors when I save the class.
public class Util {
@future
public static void insertUserWithRole(
String uname, String al, String em, String lname) {
Profile p = [SELECT Id FROM Profile WHERE Name='Profile_ID__c'];
UserRole r = [SELECT Id FROM UserRole WHERE Name='Role_Id__c'];
// Create new user with a non-null user role ID
User u = new User(alias = 'New_Acquisition_Alias', email='New_Acquisition_User_Email__c',
emailencodingkey='UTF-8', lastname='New_Acquisition_User_Last_Name__c',
languagelocalekey='en_US',
localesidkey='en_US', profileid = p.Id, userroleid = r.Id,
timezonesidkey='Europe/London',
username='Europe/London');
insert u;
}
}