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
sai kumar 625sai kumar 625 

Detail Page Link in Managed Package.

Hello All,
We are displaying report through detail page links on our custom objects. But the issue is when I install this as a package, in the target org the report is not getting displayed because report ID gets changed from org to org.Moreover I am not able to edit this detail page link as it is a managed pacakge componenet. So any suggestion for this or any alternative for this. Your help will be really appreacated.
Rishab TyagiRishab Tyagi
Hello Sai,

Passing Id directly in a managed package is never a good option. You can instead query the Id of the report using this query in your package:

SELECT DeveloperName,Id FROM Report WHERE DeveloperName = 'test_rep' limit 1

Hope that answers your question.
sai kumar 625sai kumar 625
Hello Rishab,

we are passing that ID in detail page link under objects. How to pass SELECT DeveloperName,Id FROM Report WHERE DeveloperName = 'test_rep' limit 1 in the detail page link, when I try the syntax throws error.

User-added image
Rishab TyagiRishab Tyagi
Hello Sai,

I am sorry it seems like there was some miscommunication from my end. However, you cannot use a simple query directly in the button. What you need to do is in behavior select execute Javascript and use javascript similar to this:
 
{!REQUIRESCRIPT("/soap/ajax/44.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/44.0/apex.js")}

var query = "select Id from Report where DeveloperName = 'opp' limit 1"; 
        
var result = sforce.connection.query(query); 
var records = result.getArray("records"); 
        
var repRec = records[0];

window.location.href = '/'+repRec.Id+'?pv0={!Account.Id}'

Also, take care that now the merge fields need to be inside single quotes otherwise the script will throw an error of unexpected token.