
// Constructor - this only really matters if the autoRun function doesn't work right
private final Case o;
String link = '';
public CustomButtonController(ApexPages.StandardController stdController) {
this.o = (Case)stdController.getRecord();
}
public PageReference autoRun() {
String theId = ApexPages.currentPage().getParameters().get('id');
if (theId == null) {
// Display the Visualforce page's content if no Id is passed over
return null;
}
List<Case> caselist = [select id, CaseNumber,Status,Type from Case where id =:theId];
for (Case o: caselist) {
if(o.Type =='Interaction'){
o.Status = 'Closed';
link = '/' + theId;
}
else
link = '/' + theId +'/s?retURL=' + theId;
}
if(caselist.size()>0)
update caselist;
if(link=='')
link = '/' + theId;
// Redirect the user back to the original page
PageReference pageRef = new PageReference(link);
pageRef.setRedirect(true);
return pageRef;
}
}
1 resposta
Venkataramana,
This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support