You need to sign in to do that
Don't have an account?
Amanda Ream
Create a trigger for new user
I am trying to create a trigger that creates a new user record when a custom object picklist is set to 'in progress'. I am getting an error that says "Illegal variable declaration: newUser.FirstName" Can anyone help me out and tell me what this error means? Here is the whole trigger, the bolded line is causing the error:
trigger AutoUserCreate on User (after update) {
List<User> UserList = new List<User>();
for( Support_Request__c sr : Trigger.new) {
if (sr.status__c == 'in progress'){
User newUser = new User ();
string newUser.FirstName = Support_Request__c.First_Name__c;
string newUser.LastName = Support_Request__c.Last_Name__c;
insert UserList;
}
}
}
trigger AutoUserCreate on User (after update) {
List<User> UserList = new List<User>();
for( Support_Request__c sr : Trigger.new) {
if (sr.status__c == 'in progress'){
User newUser = new User ();
string newUser.FirstName = Support_Request__c.First_Name__c;
string newUser.LastName = Support_Request__c.Last_Name__c;
insert UserList;
}
}
}
Change the trigger like this.
trigger AutoUserCreate on User (after update) {
List<User> UserList = new List<User>();
for( Support_Request__c sr : Trigger.new) {
if (sr.status__c == 'in progress'){
User newUser = new User ();
newUser.FirstName = Support_Request__c.First_Name__c;
newUser.LastName = Support_Request__c.Last_Name__c;//insert all required fields.
insert UserList;
}
}
}
Thanks.
You need to write a trigger in custom obj. which is having that picklist. I hope its in Support_Request__c.
Please write a trigger in Support_Request__c like this.
And sorry for the dealy.
Thanks.
Praveen Murugesan.