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

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

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .