4

I have created a Flow which allows my users to insert multiple Currency_Detail__c records from one page.

The Currency Detail records have a Master-Detail relationship with Opportunities. I have created a variable in the Flow OppId which, as the name suggests, will store the Id of the Opportunity which each Currency Detail record needs to be related to.

I now need to add a custom button to the Currency Detail related records list, to launch the Flow and to populate the OppId variable, with the Id of the Opportunity which the user is viewing.

I've created this VisualForce page

<apex:page standardController="Currency_Detail__c" recordSetVar="Currency_Details">
   <flow:interview name="Create_Currency_Detail_Records" finishLocation="/{!Id}"/>
   <apex:param name="OppId" value="{!Id}"/>
</apex:page>

But when I use this, it causes an error

(REQUIRED_FIELD_MISSING) Required fields are missing: [Opportunity__c] --- for SFDC record with ID : null

so it looks like the variable's not being populated.

This is probably completely off the mark but I can't save the page if I change value="{!Id}" to value="{!Opportunity.Id}"

Unknown property 'Currency_Detail__cStandardController.Opportunity'

How can I populate the Flow's OppId variable from the VisualForce page?

UPDATE

Just to make sure that the setup of my Flow's not the cause of the issue, this is how the Record Create elements are configured

Record Create Screen

The other two fields are taking their values from screen input fields on a screen element earlier in the Flow.

The OppId variable is set to Input & Output.

4

You have to make the Custom Button as an onclick javascript button and then open the VF Page by passing the opportunity id as a parameter to the page (say call id oppId) and then pass that parameter to the flow..

so your Custom Button properties will be

  • Display Type - List Button
  • Behaviour - Execute Javascript
  • Content Source - Onclick Javascript

and then in the script section point it to your VF page with the param

window.location = '/apex/YourVFPage?oppId={!Opportunity.Id}'

then in your VF page you can do

UPDATE :

the param tag was outside the flow tag which is why the value was not getting passed into the flow.. please use the correct syntax as below

<apex:page standardController="Currency_Detail__c" recordSetVar="Currency_Details">
   <flow:interview name="Create_Currency_Detail_Records" finishLocation="/{!Id}">
       <apex:param name="OppId" value="{!$CurrentPage.parameters.oppId}"/>
   </flow:interview>
</apex:page>
  • Thanks Vamsi but I get 'unexpected token ILLEGAL' when I click the button, having made those changes. – Alex S Jul 19 '15 at 11:15
  • i jus gave a rough idea on the redirection. you have to use window.location assignment syntax.. just updated the code. – Vamsi Krishna Jul 19 '15 at 11:29
  • That's fixed the 'ILLEGAL' error but I'm still getting the first 'required fields are missing' error – Alex S Jul 19 '15 at 11:36
  • can u share your flow details where you are creating the currency detail records and relating them to opportunity id passed in the variable ? – Vamsi Krishna Jul 19 '15 at 12:01
  • and did u mark the oppId variable in the flow as input variable ? – Vamsi Krishna Jul 19 '15 at 12:05

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.