• samson sfdc
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I'm trying to update the User object (Commmunity Portal user) whenever the details like First Name, last name, email & phone are update in Contact object.

Apex Class
----------------
global class UpdateUserfromContact{ 
    public static void updateUsers(String ConId) {
        Contact cont = [select Id,Email,FirstName,LastName,Phone
                    from Contact
                    where Id=:ConId];                    
        if (cont!=null && cont.Id!=null) {   
            User usr = new User(ContactId=cont.Id,Email=cont.Email,FirstName=cont.FirstName,LastName=cont.LastName,Phone=cont.Phone);
            update usr;
        }
    }
}


Trigger on Update Contact
-------------------------------------
trigger cc_hug_UpdateUserfromContact on Contact (after update) {

    if (Trigger.new.size()==1) 
    { 
        Contact u = Trigger.new[0];
        if (u.Id!=null) {
            cc_hug_UpdateUserfromContact.updateUsers(u.Id); 
        } 
    } 
}
 
I'm New to Apex coding,  I have requirement where I need to insert 500000 records into an object using Batch Apex.
It can be done via Data loader, but I wanted to try it using Batch Apex. guide me please.
Thanks in advance.
I have an email template where i'm listing all the products purchased by the customer. When the customer purchased a bundle product, I have to show the product name as a main item then indent the inline product items in the bundle.
Ex. 
1. Canon Camera bundle
        Wide anlge Lens
        Tripod
        Remote switch
        Camera bag
2. Memory Card
3. Baterry
4. Flash
I'm New to Apex coding,  I have requirement where I need to insert 500000 records into an object using Batch Apex.
It can be done via Data loader, but I wanted to try it using Batch Apex. guide me please.
Thanks in advance.
I'm trying to update the User object (Commmunity Portal user) whenever the details like First Name, last name, email & phone are update in Contact object.

Apex Class
----------------
global class UpdateUserfromContact{ 
    public static void updateUsers(String ConId) {
        Contact cont = [select Id,Email,FirstName,LastName,Phone
                    from Contact
                    where Id=:ConId];                    
        if (cont!=null && cont.Id!=null) {   
            User usr = new User(ContactId=cont.Id,Email=cont.Email,FirstName=cont.FirstName,LastName=cont.LastName,Phone=cont.Phone);
            update usr;
        }
    }
}


Trigger on Update Contact
-------------------------------------
trigger cc_hug_UpdateUserfromContact on Contact (after update) {

    if (Trigger.new.size()==1) 
    { 
        Contact u = Trigger.new[0];
        if (u.Id!=null) {
            cc_hug_UpdateUserfromContact.updateUsers(u.Id); 
        } 
    } 
}
 
I have an email template where i'm listing all the products purchased by the customer. When the customer purchased a bundle product, I have to show the product name as a main item then indent the inline product items in the bundle.
Ex. 
1. Canon Camera bundle
        Wide anlge Lens
        Tripod
        Remote switch
        Camera bag
2. Memory Card
3. Baterry
4. Flash