0

Currently, converting a Javascript List Button to a List Button that uses a VisualForce Page.

The button is on a related list on the Opportunity layout.

Is it possible to grab Opportunity fields if the standard controller is a different object?

error: Unknown property 'OpportunityRequest__cStandardController.Opportunity'

<apex:page standardController="OpportunityRequest__c" recordSetVar="OpportunityRequests">

<script>
    if('{!Opportunity.Name}' != ''){
    parent.window.location='/apex/oppRequest?&oppId={!Opportunity.Id}'
    }
</script>

</apex:page>

1 Answer 1

0

Yes, you should be able to get the data via the custom lookup field:

if({! NOT(ISBLANK(OpportunityRequest__c.Opportunity__r.Name)) }) {

I'd have to experiment a bit more to see what other changes you'd need to make, but this should help you get started.

3
  • The OpportunityRequest__c does not exist yet. If the Opportunity Name is not blank the user will be redirected to an apex page which has a form to create an OpportunityRequest. Commented Jun 4, 2019 at 19:43
  • @ebar It doesn't need to exist. The object name is a merge field used to represent the object in memory, which should already have the opportunity populated, if I'm remembering correctly. Commented Jun 4, 2019 at 19:45
  • So if I'm on an opportunity page and I click the button on the OpportunityRequest__c related list. And I alert('{!OpportunityRequest__c.Opportunity.Id}'); it will show the Id of the opportunity that im on? Commented Jun 4, 2019 at 19:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.