• User One 35
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 14
    Replies
I want to auto update Account address when I create Contact and save account address should save in contact address by using process builder and Apex please can anyone help me on this 
I am trying to update when Account Address is created and it should autoupdate the Contact Addres by uing Flow and Process Builder here is the steps 
Step One : 
Create a Flow with Variables - 
UniqueName: VarAccountId
Data Type: String
Input / Output Type: Input and Ouput
Default Variable: {!$GlobalConstant.EmptyString}

Step Two Create a Flow with Sobject 
Unique Name: AccountObject
Input / Output Type: Input and Ouput
Object Type: Account

Step Three:
Create a Flow with FastLookup
Query the Object: Account
Filter: 
Id equals VarAccountId
User-added image
Create Flow With  Update Record 
User-added image

Done with Flow 
Adding Flow in Process Builder to Update Account Address to Contact Address to autoupdate 

User-added image

User-added image

User-added image
In Account Detail 
Building Address 525 N Lington Ave. When I created contact it displaying old address in Mailing Address 525 S Lington Ave.

 
Display all Child Records on Parent Object
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
I want to display all child records on parent detail page ( when I open the parent object  it show  all child records and how many records are in child) use apex code, please help on this I am new to coding side, I really don't know how to do please any one help me in simple steps 
I am trying to create a Account record when the account record is saved automatically create a contact record. I tried with only trigger its working but I want to write trigger and handler class  but its not working 

//Tigger

trigger AccountContact on Account(after insert, after update) {
        if(Trigger.isInsert){
                 AccountTriggerHandler.createContact(Trigger.new);
     }
  }

// Handler Class 
Public class TriggerHandler{
           List<Contact> ct = new List <Contact>();
               for(Account acc : trigger.new){
                     Contact c = new Contact(LastName = acc.name,
                                                               AccountId=acc.id,
                                                               Fax=acc.Fax,
                                                               Phone=acc.Phone);
        ct.add(c);
    }
    insert ct;
}
I want to auto update Account address when I create Contact and save account address should save in contact address by using process builder and Apex please can anyone help me on this 
I am trying to update when Account Address is created and it should autoupdate the Contact Addres by uing Flow and Process Builder here is the steps 
Step One : 
Create a Flow with Variables - 
UniqueName: VarAccountId
Data Type: String
Input / Output Type: Input and Ouput
Default Variable: {!$GlobalConstant.EmptyString}

Step Two Create a Flow with Sobject 
Unique Name: AccountObject
Input / Output Type: Input and Ouput
Object Type: Account

Step Three:
Create a Flow with FastLookup
Query the Object: Account
Filter: 
Id equals VarAccountId
User-added image
Create Flow With  Update Record 
User-added image

Done with Flow 
Adding Flow in Process Builder to Update Account Address to Contact Address to autoupdate 

User-added image

User-added image

User-added image
In Account Detail 
Building Address 525 N Lington Ave. When I created contact it displaying old address in Mailing Address 525 S Lington Ave.

 
Display all Child Records on Parent Object
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
I want to display all child records on parent object  here is my code 
But it displaying only contact records, I want to display all records which related to the parent object (it means all child objects records should display in parent Account object) please help me how to use triggers here.

Apex Code:
public class ContactsRecordsToAccounts{
  
    Public Id accID;
    public List<Contact> contactList{get;set;}
    public ContactsRecordsToAccounts(){
   contactList = new List<Contact>();
   accID=  ApexPages.currentPage().getParameters().get('acId');
   contactList =  [SELECT FirstName,LastName,Email,Phone FROM Contact WHERE AccountID = : accID];
 }
}

Visualforce Page Code:

<apex:page controller="ContactsRecordsToAccounts" sidebar="false" showHeader="false">
     <apex:pageBlock >
           <apex:pageBlockTable value="{!contactList}" var="con">
                      <apex:column value="{!con.FirstName}"/>
                       <apex:column value="{!con.LastName}"/>
                       <apex:column value="{!con.Phone}"/>
                       <apex:column value="{!con.Email}"/>
           </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
I am trying to create a Account record when the account record is saved automatically create a contact record. I tried with only trigger its working but I want to write trigger and handler class  but its not working 

//Tigger

trigger AccountContact on Account(after insert, after update) {
        if(Trigger.isInsert){
                 AccountTriggerHandler.createContact(Trigger.new);
     }
  }

// Handler Class 
Public class TriggerHandler{
           List<Contact> ct = new List <Contact>();
               for(Account acc : trigger.new){
                     Contact c = new Contact(LastName = acc.name,
                                                               AccountId=acc.id,
                                                               Fax=acc.Fax,
                                                               Phone=acc.Phone);
        ct.add(c);
    }
    insert ct;
}