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
uptime_andrewuptime_andrew 

Clone Button on VF Page Leads to Error

I'm using a commandButton on a Visualforce page to override the Case View.

 

<apex:commandButton action="{!clone}" value="Clone"  />

 

When clicking this, I get the following error:

 

"Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.adapters.ApexObjectValueELAdapter"

 

Do I need to do a custom PageReference function in my extension class to handle this?  I thought I would be able to do this with a standard button?

https://cs3.salesforce.com/apex/uptimeCaseView?id=500Q0000003JhDe
Best Answer chosen by Admin (Salesforce Developers) 
uptime_andrewuptime_andrew

Thanks Jill.  I managed to get it working through an input tag:

 

                <input value="Clone" class="btn" name="CloseCase" 
                onclick="navigateToUrl('/apex/myCaseEditPage?clone=1&id={!case.id}&retURL=%2F{!case.id}')" 
                title="Close Case" type="button" />

 

All Answers

jwetzlerjwetzler

Hm that is not cool. You're using the standard controller for Case + an extension? Does your extension class have a field or a method in it called clone, by chance?

jwetzlerjwetzler

Oh sorry, it appears that clone is not a method on the standard controller: http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/apex_pages_standardcontroller.htm?SearchType=Stem

 

So yeah you will need to implement this yourself. This should work, with the caveat that it's a bit of a hack to put clone=1 at the end of your URL, I'm not sure that is documented as being officially supported but it should be stable enough for you.

 

<apex:page standardController="case">
<apex:form >
<apex:commandButton value="Clone" action="{!URLFOR($Action.case.edit, case.id, [clone='1'])}"/>
</apex:form>
</apex:page>

 

uptime_andrewuptime_andrew

Thanks Jill.  I managed to get it working through an input tag:

 

                <input value="Clone" class="btn" name="CloseCase" 
                onclick="navigateToUrl('/apex/myCaseEditPage?clone=1&id={!case.id}&retURL=%2F{!case.id}')" 
                title="Close Case" type="button" />

 

This was selected as the best answer
goabhigogoabhigo

Thanks Jill, that works like a charm :)