Skip to main content
public class CustomButtonController {

 

    // 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
  1. 4 de nov. de 2014, 04:47
    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
0/9000