• Manikanta maram 9
  • NEWBIE
  • 15 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Problem

The business wants to validate certain fields on Account object for new accounts that are created or for updates to existing accounts.

Business Requirements

The following are the requirements that must be implemented:
 
  1. Ensure that the Billing Country and Shipping Country fields have a valid ISO country code, as per the CSV data sheet provided.
    1. You will find a CSV called ‘CountryList’ in the Static Resources of the sandbox
  2. The VAT Number is required for some EUROPEAN countries, check if the VAT Number is required from the CSV data sheet provided.
  3. Insert the region value into the Region field on Account object for valid records.
  4. Ensure support for user specific local error messages so global offices can use this application.
  5. A VAT Number should be in the following format:
    1. ISO country code - 10 digits example: AF-0123456789
  6. Error messages should be shown appropriately for incorrectly formatted VAT number: “An incorrectly formatted VAT number was entered”
trigger updateaccount on Contact (after update) {
    map<id,contact> conmap = trigger.newmap;
    set<id> allconids = conmap.keySet();
    list<account> acclist = [select id,phone from account where id in: allconids];
    for (account acc : acclist){
        
       acc.Phone = conmap.get(acc.Id).phone;
    }
update acclist;
trigger updateaccount on Contact (after update) {
    map<id,contact> conmap = trigger.newmap;
    set<id> allconids = conmap.keySet();
    list<account> acclist = [select id,phone from account where id in: allconids];
    for (account acc : acclist){
        
       acc.Phone = conmap.get(acc.Id).phone;
    }
update acclist;