]3I am trying to display related opportunities record related to particular account using a custom button over account detail page.
To achieve this requirement, i have created a formula field over opp. object that will store related object ID, and then created a dynamic report where i have filter data based on the formula field.
But when i click on view All Opportunities button over account page it is throwing error. Please see the attached screenshot for the same.Error1
Code :
{! REQUIRESCRIPT ("/soap/ajax/30.0/connection.js")};
{! REQUIRESCRIPT ("/soap/ajax/30.0/apex.js")}
var recordIDs = '{!Account.Id}';
// Get Opportunity records related to account
Var results = sforce.connection.query ("Select Id,AccountID, from Opportunity where AccountID='{!Account.Id}'");
results = results.getArray ("records");
var recId;
for(var i = 0;i< results.length;i++){
recId = results[i].Id;
recordIds = recordIds +","+recId.substring(0,15);
}
var reportId = '{!$Label.ViewAllOpportunitiesReportID}';
window.open("/"+reportId+"?pv0="+recordIds,"_blank");
window.parent.location='/'+'{!Account.Id}';