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
Ajay DubeyAjay Dubey 

How to get base url in managed package?

I have a requirement where I need to get Base URL in managed package class. I am using Url.getSalesforceBaseUrl().toExternalForm() to get base URL but getting
https://custom-domain-name--prefix.ap2.visual.force.com instead of https://custom-domain-name.my.salesforce.com 
Thanks in advance.
Best Answer chosen by Ajay Dubey
Amit Chaudhary 8Amit Chaudhary 8
You can create one custom setting and store base URL there and use the same custom setting to use in your code.


 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
You can create one custom setting and store base URL there and use the same custom setting to use in your code.


 
This was selected as the best answer
Ajay DubeyAjay Dubey
Hey Amit ,
Thanks for your suggestion . But in this procedure user need to create record in custom setting. Is there any other way ? because I want to automate the procedure    
Ajay DubeyAjay Dubey
Thanks Amit,
I have created custom setting and included that setting in package . Using post install script I am able to get base url of the Org and inserted a record in Custom setting.