How to query remote site settings from Apex

0 votes

I have a future method that makes a callout to a .net application. Near the top I have the hard coded declaration:

private static final String SERVICE_URL = 'https://outside.site.com';

which I use later in a setEndpoint call on an HttpRequest object.

This string occurs in remote site settings - it has to, for it to work. The value of the string is different between the sandbox and production, but the name of the remote site setting object is the same - 'Broker'. I would like to eliminate this hard coded string and use the name 'Broker' to find the remote site setting object and set the endpoint to its URL - one less thing to worry about when moving between sandbox and production.

Although I see many examples of how to create a remote site setting using metadata or tooling, I have found no examples of how to query one, just dozens of other people asking how to do it.

What is the best, simplest way to eliminate this hard code?

Mar 17, 2022 in SalesForce by surbhi
• 3,810 points
1,211 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In SalesForce

0 votes
1 answer

How to add days to date time in Salesforce Apex?

Beware the DST issue! The "addDays" function ...READ MORE

answered Mar 15, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 19, 2023 by Khan Sarfaraz 6,440 views
0 votes
0 answers

How to Write the Test class for Salesforce Apex Aura Enabled class?

stuck in here to write a test ...READ MORE

Mar 15, 2022 in SalesForce by surbhi
• 3,810 points
1,673 views
0 votes
1 answer
0 votes
1 answer

How to use Database.Statful in batch apex

Move your insert to the finish method: global ...READ MORE

answered Mar 17, 2022 in SalesForce by CoolCoder
• 4,400 points
1,653 views
0 votes
0 answers

Salesforce API: How to identify a Case from an email reference code ("[Ref: ... :Ref]")?

1 I'm writing a Windows service that will ...READ MORE

Apr 5, 2022 in SalesForce by surbhi
• 3,810 points
588 views
0 votes
0 answers

Salesforce Apex SingleEmailMessage with Template to User not contact

Im trying to send an email in ...READ MORE

Feb 28, 2022 in SalesForce by surbhi
• 3,810 points
2,815 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
2,772 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
747 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
486 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 547 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP