You need to sign in to do that
Don't have an account?
Aqua Matrix
I want help in writing trigger.
Hi,
I had created data in the custom metadata for city and zipcode...
I want to write the apex trigger to autopopulate the cityname If I select the zipcode which s present in the custom metadata...
Could you please help me to write the trigger for the above scenario...
I had written the apex code to fetch the custom metadata
And now I want to write the trigger to autopopulate the city name if we choose the zipcode.
I had created data in the custom metadata for city and zipcode...
I want to write the apex trigger to autopopulate the cityname If I select the zipcode which s present in the custom metadata...
Could you please help me to write the trigger for the above scenario...
I had written the apex code to fetch the custom metadata
And now I want to write the trigger to autopopulate the city name if we choose the zipcode.
trigger Autopopulate on Contact (after insert) { // When a new account is created, fill in the city and state based on zip code if (trigger.isAfter && trigger.isInsert) { zipcodemetda.fetchAllMetadata(); } }
There are two ways out here:
Approach 2:1.> If the number of records in the metadata is less then you can directly query all the metadata records.
2.> If the number of records in the metadata is more then you should get all the zipcodes first and then query the metadata.
Approach 1:
Handler Code
All Answers
There are two ways out here:
Approach 2:1.> If the number of records in the metadata is less then you can directly query all the metadata records.
2.> If the number of records in the metadata is more then you should get all the zipcodes first and then query the metadata.
Approach 1:
Handler Code
Thank you so much Anju Kumar
For example if I create the zip code 560 083 and once I save it it will autopolate the corresponding city
But once I edit the record and change the zipcode to 560 043 then the city name is not getting change instead it remains as it is
What's the reason for this
Is it because of trigger before insert.
please help me solve this.