I have an Apex Trigger for a Salesforce integration that looks like this in the Sandbox environment:
trigger Trigger_5074086a_493f_48d2_a8fd on Opportunity (after insert, after update, after delete, after undelete) {
String url = 'https://test.dev.wi.com/api/hook/agh0UD9J0kio_Qd';
String accessKey = '2c072ad68ac3039fca9fa868a3033f95ea165213136f';
String content;
if (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete) {
content = wiWebHook.json(Trigger.newMap.keySet());
} else {
content = wiWebHook.json(Trigger.oldMap.keySet());
}
wiWebHook.callout(url, content, accessKey);
}
}
The problem with this is that the string URL and Access Key are hard coded in the Trigger and they are only valid for my Dev Site. The String URL and Access Key is different for Production.
I have created a Custom Settings object called WILead__c with 2 fields which each contain the correct URL:
String_URL_Dev__c has a value of
String_URL_Live__c has a value of
I have also created a Custom Settings object called WIAccessKey__c with 2 fields which each contain the correct access key:
WIAccessKey__c.String_Access_Key_Dev__c has a value of
2c072ad68ac3039fca9fa868a3033f95ea165213136f
WIAccessKey__c.String_Access_Key_Live__c has a value of
128jkg785788ddff559939fca9fa868a3033f95ea165
My question is, how do I update my Trigger code so that when the Trigger is used in Sandbox it uses the WILead__c.String_URL_Dev__c and WIAccessKey__c.String_Access_Key_Dev__c values, and when it is run in Production it uses the WILead__c.String_URL_Live__c and WIAccessKey__c.String_Access_Key_Live__c values?