You need to sign in to do that
Don't have an account?

Help with visual force button extension
So, it has been a while and can't seem to remeber quite who to do this. I am making a custom Visual Force button for the case object that when pushed, changes the status of the case.
Here is my VF:
<apex:page standardController="Case" extensions="CaseRecallButton">
<apex:form >
<apex:commandButton value="Com - Recall Case" action="{!ReCallCase}" />
</apex:form>
</apex:page>
Here is my extension:
public with sharing class CaseRecallButton {
Case CA;
public CaseRecallButton(ApexPages.StandardController controller) {
this.CA = (Case)Controller.getRecord();
}
public PageReference ReCallCase(){
CA.Status='New RECALL';
Update CA; }
}
And here is my error message:
Error: CaseRecallButton Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 11 column 9
Thanks in advance for the help :)
Here is my VF:
<apex:page standardController="Case" extensions="CaseRecallButton">
<apex:form >
<apex:commandButton value="Com - Recall Case" action="{!ReCallCase}" />
</apex:form>
</apex:page>
Here is my extension:
public with sharing class CaseRecallButton {
Case CA;
public CaseRecallButton(ApexPages.StandardController controller) {
this.CA = (Case)Controller.getRecord();
}
public PageReference ReCallCase(){
CA.Status='New RECALL';
Update CA; }
}
And here is my error message:
Error: CaseRecallButton Compile Error: Non-void method might not return a value or might have statement after a return statement. at line 11 column 9
Thanks in advance for the help :)
This might work for you.
Create a VF page that's only role is to call a method on a class that sets the status, owner then redirects back to the page your on. Then you can create the comman button to cal this VF page.
Extensions Class
All Answers
This should work for you.
So this mostly works, here is the weird thing, I created a custom button, Content Source / Visual Force page and selected open in same window, I then added this button to my page layout. But when I click the button, the page reloads, the case is gone and all that is on the screen is the button. The case record was not updated. Now, if push the button on the page that loaded after I pushed the button the first time, the case does in fact update, but the page never reloads to show the case, just the empty page with the button is all that appears still.
Any suggestions?
Not sure what your trying todo... Kind of reading between the lines it sounds like each time you create a new Case there are conditions when you wan to set the status to 'New Recall'. If that is true you may want to go with a Trigger.
If that's not the case. Tell me more about the cenario that your working on and I'll try to help.
Thanks,
1. A partner of ours, via Salesforce Communities, creates a Case to request whatever action which routes to our OPS group.
2. The partner decides, before the Case is completed, to cancel / recall the Case.
3. The partner pushes the "Recall Case" button and the case’s status changes from X to “Recalled” owner changes from Y to the name of the person who pushed the button.
I figure, if we get this to the point where the status updates, I can figure out how to change the owner myself.
In the past, with Salesforce’s PRM Portal, I was able to use this to do this function:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!User.Id}';
caseObj.Status = 'Request Recalled';
var result = sforce.connection.update([caseObj]);
if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload(true);
}
But now that we are migrating to Salesforce Communities, and we are using the tabbed version of Communities, the /SOAP/AJAX/ scripts are not available. Which is why I am trying to do this with Visual force and apex/extension.
This might work for you.
Create a VF page that's only role is to call a method on a class that sets the status, owner then redirects back to the page your on. Then you can create the comman button to cal this VF page.
Extensions Class
Thanks again!