0

I have a page which which shows fields of case in better ui. Now I have to create a button on opp named create case. After clicking create case it should create a case with some similar fields on opportunity and show the same page. How can i do this?? Any help would be apprecitaed. Please let me know if anything is unclear. Thanks, Manohar

3
  • where is that button, on custom VF page or standard page. if it is on VF page, you can do easily with constructor. And if it is on standard page, use AJAX toolkit, it will help you to write queries in JS and there is an option to have a js on button while creating it.
    – Ysr Shk
    Sep 3, 2016 at 14:27
  • @YsrShk even standard page custom buttons can reference VF pages, JavaScript custom buttons won't work in LEX. Quick Actions work well in Chatter feed and LEX
    – cropredy
    Sep 3, 2016 at 16:19
  • @Ysr Shk Thanks for your comment guyz. I made it working. Thank you very much
    – Manohar
    Sep 6, 2016 at 7:23

1 Answer 1

0

I think, you should create custom visual force page and controller.

Page:

apex:page standardController = 'Opportunity' extension='yourCustomController' action="{!createCase}"

and in proper tags insert:

window.top.location.href = '{!redirectUrl}'.

Controller: Contsuctor should take (ApexPages.StandardController controller) argument and then you can take current opportunity with

controller.getRecord method.

Then, in controller implement method named createCase which return PageReference Type - in your case, and return there null; In this method you can create your case, and initialize redirectUrl variable by:

redirectUrl =stdController.view().getUrl();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .