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
BellaBella 

Apex equivalent for {!API.Partner_Server_URL_80}?

Could someone please tell me what is the apex equivalent for {!API.Partner_Server_URL_80}? I'm trying to create a page reference for Conga Merge. Also does {!API.Session_ID} == UserInfo.getSessionId()? Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
mancemance

I just came up with a solution to this:

 

Make a formula field on the object you are working with that points to the {!API.Partner_Server_URL_80}. Then query that field out in your controller and you should be able to use it.

 

Why its not in Apex/VF but only availble in formula fields/buttons baffles me.

All Answers

gv007gv007

String serverURL = ApexPages.currentPage().getHeaders().get('Host');

String sessionId =UserInfo.getSessionId();

 

us the following code in yours controller.

BellaBella

Thank you! :smileyhappy:

mitesh_mistrymitesh_mistry

I am having the same problem and unfortunately the fix above did not resolve my issue. The code i am using is as follows:

 

String sessionID = Userinfo.getSessionId();
String partnerServerURL = ApexPages.currentPage().getHeaders().get('Host');
String accId = account.Id;
String accName = account.Name;

 

genContractsLink = 'https://www.appextremes.com/apps/Conga/PointMerge.aspx?' +
                                'sessionId=' + sessionID +
                                '&serverUrl=' + partnerServerURL +
                                '&id=' + accId +
                                '&ReportID=00OT00000017RiM,00OT00000017RiR,00OT00000017RiW,00OT00000017Rjy,00OT00000017Rk3,' +
                                '&templateid=a1sT0000000Ceia' +
                                '&defaultpdf=true' +
                                '&ofn=Performer+Contract+-+' +
                                accName +
                                '&ds7=3' +
                                '&ocnr=1';

 

I receive the following error message when i click on the link from the visualForce page:

 

Not a valid Salesforce server: c.cs0.visual.force.com

 

which means that my partnerServerURL is returning 'c.cs0.visual.force.com' which is incorrect given the error message.

 

Thanks.

BellaBella

Oh actually I have the same problem too. One of my buttons is directly on the page so the above works but the other is through VisualForce. Any solution to that would be increadibly helpful for me too.

FilikinFilikin

Hi,

did you ever get a solution to this? I am having the same problem generating a url for Conga Merge.

mancemance

I just came up with a solution to this:

 

Make a formula field on the object you are working with that points to the {!API.Partner_Server_URL_80}. Then query that field out in your controller and you should be able to use it.

 

Why its not in Apex/VF but only availble in formula fields/buttons baffles me.

This was selected as the best answer
Koen (BvD)Koen (BvD)

I posted an alternative solution (but still only a workaround to a hiatus in the apex api) in this thread

similar question

using a component and a static property

 

bhalodi dhruvbhalodi dhruv
@mitesh_mistry
Please use this
String sSessionID = UserInfo.GetSessionId();
        String sOrgID = UserInfo.getOrganizationId().substring(0,15);
       
        String sCongaUrl = 'https://www.appextremes.com/apps/Conga/PM.aspx?sessionId=';
      
            String docUrl = sCongaUrl
                        + sSessionID
                        + '&serverUrl='
                        + EncodingUtil.urlEncode( URL.getSalesforceBaseUrl().toExternalForm(), 'UTF-8')
                        + '%2Fservices%2FSoap%2Fu%2F9.0%2F'
                        + sOrgID