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
steven75steven75 

Passing Opportunity to the new case

When I create a new case from Account, it pass then URL string like this so New Case creation page automatically has the Account selected in the text box.

https://na5.salesforce.com/500/e?retURL=%2F0017000000cPwLr&def_account_id=0017000000cPwLr

 

Is there a way to do samething in for Opportunity? where I can pass the string to New Case creation page and Opportunity automatically show in Opportunity box in New Case creation page?

 

Thanks,

mtbclimbermtbclimber

Yes, there are couple of options. I presume you have a custom lookup from case back to oppty:

 

Override New button (for case):

 

  1. Your target page utilizes the standard controller for case, i.e. standardController="Case".
  2. Override the new Button (action) for case with your button, see Setup > App Setup > Customize > Case > Buttons & Links

The lookup field value should be populated automatically in this case if you are binding to the standard controller provided record, i.e.

 

 

<apex:inputField value="{!case.opportunity_lookup__c}"/>

 

Custom button on oppty page to create case from oppty:

 

  1. Your target page has either a standard controller extension or custom controller in apex where you look for a request parameter that you define and default the value accordingly.
  2. Create a custom button on opportunity that sets the opportunity id to the request parameter you defined in your code.

 

Hope that helps.

steven75steven75

Thanks for quick response.  Your information seems really helpful, however I am new to SalesForce, therefore I couldn't follow exactly, SORRY!

Let me briefly describe what I am having now so you can help me in steps to make this happen.

 

1. I created a button call "New Case" using Setup/Customize/Case/Buttons and Links.   This button creatted as List Button, Behavior = "Display ... without sidebar and header, under Select Field Type/Insert Field, I put this String "/500/e?retURL=%2F500%2Fo" so it links to the New Case page.

2. Next, I go to Setup/Customize/Opportunity/Page Layout, scroll down to the Case, click the little "wrench" icon, then add the "New Case" button I created earlier.

3. Also, in Setup/Customize/Case/Fields,  I also have a custome field called "Opportunity", this field has lookup option set to Related To "Opportunity" object.

4. After that, I have the button New Case in Opportunity Record view that links to the New Case page, but not able to capture the Opportunity.

 

Thanks in advance for help,

 

 

 

mtbclimbermtbclimber

Let's back up then.

 

What do you need to do that the standard "New" button on the case related list on opportunity doesn't already?

steven75steven75

There are two things I want to accomblish:

 

1.  I would like to have an Opportunity field in the Case, therefore I create a custom field in Seup/Customize/Case/Fields using Lookup Type to Opportunity.

2.  I would lke to have a New Case button from an Opportunity Record view.   There is no button to create new case from Opportunity Record view (the New Case button only available in Acccount and Contact view).    Therefore, I create a custom button New Case in Setup/Customzie/Case/Buttons and Links and then add that button to the Opportunity Page Layout add describe above.

 

Please advise,

mtbclimbermtbclimber

Apologies. It looks like you are more familiar with the nuance of related lists for the standard case object than me.  For some reason case related lists established by a custom lookup to what appears to be a very few entities (Opportunity included obviously) do not include the standard "New" button as is the case for all other entities which I have tested.

 

I've created a bug to track this. Please contact support to log a case and have them attach this bug # for you: W-773519

 

Aside from that being addressed your options here go back to my first response (specifically the second option, obviously). You can't do this in a supported manner without Visualforce.

steven75steven75

I am lost with "the second option",  can you please show me the steps how to do that if possible?

 

Thanks,