function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AmayAmay 

How to make endpoint URL of callout configurable in Salesforce which is being used in Apex code

I'm trying to integrate my system with salesforce and want to package my components (triggers and classes).

I'm trying to create a package for my app, so that customers can directly install it from the URL i.e unmanaged package. Currently, I have created a Custom Metadata so that cliet can configure the URL, Token and other authentication details. These authentication details will be filled as a custom metadata record and my endpoint from Apex class will then be called to send the necessary information.

My question is 

Is there any better way to make the installation of unmanaged packages more flexible because right now customers will have to set up a new record providing the URL and token details which can change for any other customer?

Best Answer chosen by Amay
Hara SahooHara Sahoo
Have you considered Named credential
Using Named Credential, we can make a call out to an external system without supplying username or Password in the code.
Easy to maintain: if an endpoint URL changes, you update only the named credential
You can skip remote site settings, which are otherwise required for callouts to external sites
More info:

https://help.salesforce.com/s/articleView?language=en_US&r=https%3A%2F%2Fwww.google.com%2F&id=sf.named_credentials_about.htm&type=5