Hey guys, today in this post we are going to learn about Write Apex Trigger, When an Account record is created then assigned the Billing Address fields value to Shipping Address fields value in Salesforce
Final Output β
Other related post that would you like to learn in Salesforce
Create Apex Trigger β
Step 1:- Create Apex Controller : AccountTrigger.apxt
SFDX:Create Apex Trigger>> New >> AccountTrigger.apxt
AccountTrigger.apxt [Apex Trigger]
|
TRIGGER AccountTrigger ON Account (BEFORE INSERT, after INSERT) {
IF(TRIGGER.isBefore && TRIGGER.isInsert){
accountTriggerHandler.billiingToShiping(TRIGGER.new);
}
}
Create Trigger Handler Controller β
Step 2:- Create Apex Controller : accountTriggerHandler.apxc
SFDX:Create Apex Trigger>> New >> accountTriggerHandler.apxc
accountTriggerHandler.apxc [Trigger Handler]
|
public class accountTriggerHandler {
public static void billiingToShiping(List<Account> accList){
FOR(Account acc:accList){
IF(acc.Status__c == TRUE){
acc.ShippingCity = acc.BillingCity;
acc.ShippingCountry = acc.BillingCountry;
acc.ShippingPostalCode = acc.BillingPostalCode;
acc.ShippingState = acc.BillingState;
acc.ShippingStreet = acc.BillingStreet;
}
}
}
}
Further post that would you like to learn in Salesforce
Can I put billing address as shipping address?
Your billing address is often the same as your shipping address, but they may be different they may be different if you've moved recently or used a post office box. Here's how to verify your billing address: Your credit card statements show your billing address if you receive the statements by postal mail.
The difference between shipping and billing address
A shipping address is an address where you or your 3PL will send the order. The billing address is the address connected to the customer's payment method. Billing and shipping addresses are often the same but not always.
Can we create custom address field in Salesforce?
To include a custom address field in a report, add the individual address components, such as street, city, state, and zip. When using a custom address field in a Data Integration Rule, the Country and State components are unavailable for field mapping.
Related Topics | You May Also Like
Our Free Courses β
π Get Free Course β
π Salesforce Administrators π Salesforce Lightning Flow Builder π Salesforce Record Trigger Flow Builder |
π Get Free Course β
π Aura Lightning Framework π Lightning Web Component (LWC) π Rest APIs Integration |