0

I'm transferring code from a managed package to a new org.

This line of code

public static string getGeocodingAPIkey(String customSettingName) {
    Google_Geocoding_API__c goecodingCustomSetting = Google_Geocoding_API__c.getValues('Default');
    String geocodingAPIKey = goecodingCustomSetting.Geocoding_API_Key__c;
    return geocodingAPIKey;
}

There is the Google_Geocoding_API__c class. When I go to my list of custom sObjects in the managed package org, it's not there.

enter image description here

The error I'm getting is

Invalid type: Google_Geocoding_API__c

  • 2
    It's a Custom Setting, not a Custom Object. If it's missing, then you need to create it... – Adrian Larson Dec 16 '16 at 19:14
  • @AdrianLarson is there anyway to know that when you look just at the code? – Tyler Zika Dec 16 '16 at 20:54
  • 1
    Yeah, it's the only way getValues, getInstance, or getOrgDefaults would ever work. – Adrian Larson Dec 16 '16 at 21:09
4

For sObjects (or Custom Settings) in a package you need the package prefix. Usually something like packagename__Google_Geocoding_API__c

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_namespace_prefix.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.