+ Start a Discussion
DeekDeek 

How to create NEW CASE button within Opportunity screen

We would like to have the ability for our Sales Reps to be able to create a new case from within an opportunity screen.  That case then would be related to that opportunity only.

 

Salesforce allows you to see related cases once you enable the relational list for cases in the layout edit mode, but does not give you a NEW CASE button anywhere in the Opportunity screen.

 

Here is what I have done so far. 

 

Under CASES > FIELDS I created a custom relationship lookup field called RELATED OPPORTUNITY | API Name: Related_Opportunity__c.  I added the new lookup field to the case layout.  It works fine from within the case screen.  I can lookup opportunities with no problem.  Under CASES > BUTTONS AND LINKS I created a new list button called NEW CASE.

 

Button Details:  

 

 

/500/e?retURL=%2F500%2Fo

&cas4_lkid={!Account.Id}

&cas4={!Account.Name}

&006M0000004yR7w_lkid={!Opportunity.Id}

&CF006M0000004yR7w={!Opportunity.Name}

&opp4={!Case.Account}

&CF00N00000007E8N3={!Case.CaseNumber}

&cas3_lkid={! NULLVALUE (Case.ContactId, Contact.Id )}

&cas3={! NULLVALUE (Case.Contact, Contact.Name )}

&cas6=Pre-Sale

&cas11=AE - Web

&retURL=/{!Opportunity.Id}

&saveURL=/{!Opportunity.Id}

 

When I hit the NEW CASE button within the opportunity screen, it takes me to new case creation screen like it should.  Some fields like Account Name gets updated with the correct info except for the RELATED OPPORTUNITY field.

 

Where am I doing wrong?  The ID of the RELATED OPPORTUNITY field is: 006M0000004yR7w

 

Please help.

 

Best Answer chosen by Admin (Salesforce Developers) 
Jeff MayJeff May

Courtesy of @Dickens3 from the Success boards:

 

Found easy answer .. Create a "NEW CASE" custom button under the Case Object.  Enter the URL from the address bar of the page you want them to be directed to. In my case I wanted a specific record type for cases created from an opportunity so my url was:  https://na2.salesforce.com/500/e?retURL=%2F500%2Fo&RecordType=012400000009dkM&ent=Case

Save the new button and then on the Opportunity layout page, go to the Case Related list section, and click on the wrench icon to edit the field - the option to add the new button is now there.

Good Luck!

All Answers

Jeff MayJeff May

Courtesy of @Dickens3 from the Success boards:

 

Found easy answer .. Create a "NEW CASE" custom button under the Case Object.  Enter the URL from the address bar of the page you want them to be directed to. In my case I wanted a specific record type for cases created from an opportunity so my url was:  https://na2.salesforce.com/500/e?retURL=%2F500%2Fo&RecordType=012400000009dkM&ent=Case

Save the new button and then on the Opportunity layout page, go to the Case Related list section, and click on the wrench icon to edit the field - the option to add the new button is now there.

Good Luck!

This was selected as the best answer
Neena BainsNeena Bains

In this section:
&006M0000004yR7w_lkid={!Opportunity.Id}

&CF006M0000004yR7w={!Opportunity.Name}

It looks like you're missing a CF (assuming thats a custom field.) And also a _lkid if that's pointing to a Lookup field

It should probably be:

&CF006M0000004yR7w_lkid={!Opportunity.Id}

&CF006M0000004yR7w_lkid={!Opportunity.Name}
Hyung Lee 20Hyung Lee 20
Neena is correct. You need to add the two CF since you have to create a custom lookup field since there's not out of the box lookup to from the opp to the case.
Steven DeYoungSteven DeYoung
I was just trouble shooting the exact same issues in our org - populating the related opportunity field via a custom New Case button. I was able to solve it by removing the "w_lkid" from the second line in Neena's answer. 

So:
&CF006M0000004yR7w_lkid={!Opportunity.Id}

&CF006M0000004yR7={!Opportunity.Name}

Works great now!
Brooke HarperBrooke Harper
I agree with Neena. You'd need to add the two CF for the custom lookup field. However, I'm glad that removing the "w_lkid" worked.
Niklas MyrnäsNiklas Myrnäs

Hi!

I'm completely new to Salesforce and URL hacking done this way.

I have the same problem as above, BUT with another field on the Case object and that is Contact Name (lookup field). I can't seem to be able to populate the field with the value from my Opportunity custom field Contact__c. Or more exact the value is shown in the field Contact Name on the case, but I get - Error: Invalid Data. If I save the case anyway it gets saved correctly using the button seen below. I have tried with cas3_lkid=, as it is a lookup field, but don't know what Id to use.

Here is my button code:

retURL=%2F500%2Fo&
accid={!Account.Id}
&cas4={!Account.Name}
&cas3={!Opportunity.Contact__c}
&CF00N0Y00000Cq2kO_lkid={!Opportunity.Id}
&CF00N0Y00000Cq2kO={!Opportunity.Name}


Can someone please tell me what I'm doing wrong here?