0

ErrorError Screenshot[![Here WhatID is the formula field which contain the related obj ID]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 Custom Button definition

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}';
  • Error is not clear in the picture. Also, put your code separately amending your question – Santanu Boral May 12 '18 at 8:32
1

Two problems in your JavaScript are:

var recordIDs = ...

Var results = ...

should be this:

var recordIds = ...

var results = ...

because JavaScript is a case sensitive language.

Pasting your JavaScript code into http://jshint.com/ is one way to find problems like this. Or when JavaScript things go wrong, you can use your browser's Developer Tools such as the messages that appear in the JavaScript console.

| improve this answer | |
0

If I understand correctly, you want to display all the Opportunities related to an Account when you click on button at Account Detail page.

So, create an Opportunity Report and pass the AccountId. You cannot pass a list of opportunities like the way you are passing.

OpportunityId

| improve this answer | |
  • Hi Santanu, I have updated the error screenshot, and in report i am passing the accountID only, as i have created a formula field on Opp. object which contain the value of accountID. – Ravi Ranjan May 12 '18 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.