7

Our application makes outbound connections to different remote sites, and installs a short list of those sites as part of the Package Installation process.

One of our custom objects is a list of accounts to access on those servers (username, password, hostname). We just ran into a problem where someone mistyped a server hostname when adding an account.

I'd like to have a trigger before insert and modify that throws an error if the user tries to add an entry for a host that isn't in the Remote Site List. The error will state that they need to either change the hostname or add the site to the Remote Site List.

The trigger won't be able to make a callout, otherwise I could just try calling out and trapping the exception. Even if I can't walk the list of Remote Sites, it'd be great to call an API that tells me whether a given URL is in there or not. For example, if HttpRequest.setEndpoint() threw an exception without having to call Http.send().

2 Answers 2

5

The remote sites list is not currently exposed in Apex.

2

Your list of remote sites should be a pretty static list, right? If so you could just make hostname a picklist that the user can choose from. You could also add a validation rule to ensure they don't add invalid options to the picklist and attempt to select them.

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.