+ Start a Discussion
Manohar kumarManohar kumar 

Need help with calling a page from a button on case

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.



NagendraNagendra (Salesforce Developers) 
Hi Manohar,

First and foremost sincerely regret the inconvenience for the delayed reply.

As this post is already answered from stack exchange community as below;

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

apex:page standardController = 'Opportunity' extension='yourCustomController' action="{!createCase}"
and in proper tags insert:
window.top.location.href = '{!redirectUrl}'.
Controller: Constructor 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();

Kindly mark this post as solved so that it gets removed from the unanswered queue and becomes a proper solution which results in helping others who are really in need of it.

Best Regards,