• CJWilder
  • NEWBIE
  • 145 Points
  • Member since 2014
  • VP App Dev Manager
  • Regions Financial

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 16
    Replies
How to redirect to a another Salesforce page from the Constructor?  Is there a sample code somewhere?   Somehow,  the setRedirect(true)  does not work from the Constructor of the class.
  • October 03, 2014
  • Like
  • 0
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 :)
Hello 

 I have 95% covergae in production , and I moving classes/triggers that have (97%) coverage in dev. 

Whan I deploy in production , I am getting the error 

Code Coverage Failure
Your organization's code coverage is 73%. You need at least 75% coverage to complete this deployment.

what am I missing here !?

Thanks 

Dear all,
             i am writing a class to display contacts of standard objects(Contact). but while writing i got above problem. so could you pls rectify the problem? suggest me how to write program? what is the need of inner class? is it compulsory to write in every class.
this is my VF Page:
<apex:page standardController="Contact">
    <apex:form >
        <apex:pageBlock title="All Contacts">
            <apex:pageBlockSection >
                <apex:dataTable value="{!contact}" var="con" border="2" cellpadding="10">
                    <apex:column headerValue="Contact Name">
                        <apex:outputField value="{!con.lastname}"/></apex:column>
                    <apex:column headerValue="Account Name">
                        <apex:outputField value="{!con.name}"/></apex:column>
                    <apex:column headerValue="Lead Source">
                        <apex:outputField value="{!con.LeadSource}"/></apex:column>
                    <apex:column headerValue="Phone">
                        <apex:outputField value="{!con.Phone}"/></apex:column>
                    <apex:column headerValue="Fax">
                        <apex:outputField value="{!con.Fax}"/></apex:column>
                    </apex:dataTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
this is my controller:
public class Contact
{
    List<Contact> conlist = new List<Contact>();
    public List<Contact> displayContacts(){
        for(Contact c:[SELECT lastname,name,leadsource,phone,fax FROM Contact]){
            conlist.add(c);
        }
        return conlist;
    }
    
    public class contactwrapper
    {
        private Contact con{get;set;}
        public contactwrapper(Contact c){
            con = c;
        }
    }
}


 
How to redirect to a another Salesforce page from the Constructor?  Is there a sample code somewhere?   Somehow,  the setRedirect(true)  does not work from the Constructor of the class.
  • October 03, 2014
  • Like
  • 0
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 :)
Hi,

I have been able to get a visualforce page working to display the results of a query with one row for each record but would like to see if it is possible to format the data differently so that I can group by a field and then display all of the values in another field in the rest of the row. An example would be:

FIELD 1      FIELD 2         FIELD 3
A                 1                     Red
A                 2                     Yellow
B                 2                      Yellow
B                 1                      Red
B                 3                      Green

To be displayed in separate cells as:

A      1(in red)        2(in yellow)
B      2(in yellow)    1(in red)        3(in green) 

Thanks in advance for any assistance.
i've confused myself

i have an object with 2 fields

Form Name (external reference and unique name that is stored within the form_id field within a different custom object)
ObjectName__c (formula field that based on name enter the correct custom object mycustomobject__c)
Salesforce_Record_Count__c (i want to put the number of records that match my search critera in here)

i then want to create a batch process that will do something like this:

global class UpdateMonitoringForms implements Database.Batchable<sObject>{

    string query;
    global Database.querylocator start(Database.BatchableContext BC){
      Query = 'Select ID,Form_Name__c,Salesforce_Record_Count__c From Monitoring_Form__c';
      return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Monitoring_Form__c> scope){
      List<Monitoring_Form__c> lstmforms = new List<Monitoring_Form__c>();  
       for (Monitoring_Form__c mf:scope) {
        string object = mf.ObjectName__c;
        IF(mf.ObjectName__c!= 'DO NOT PROCESS'){
          mf.Salesforce_Record_Count__c = [select count() from object where Form_ID__c =:mf.Form_Name__c];
        }
        lstmforms.add(mf)
        }
        update lstmforms;       
    }

    global void finish(Database.BatchableContext BC){

    }
}

so basically my challenge is how can I build my select count to use potentially a different customobject__c each time it runs.

I plan to limit this batch to only updating 20 records at time.

any thoughts or betters ways of doing this, please do as for clarification.

dan


I have to to write a trigger on object Primary application allocation that is related to opportuniity and 
when atlease 1 record is created, set the opportunity.primary_application_allocation_set check mark = true
and
And when all the primary application records are deleted, set the opportunity.primary_application_allocation_set check mark = false ..

I was facing problem with this to write a trigger. so please can any one help on this..
Hello , 

I have an approval process on custom object where I want 2 related user to be assigned as approvers , I defined the approval step for this and everything works fine when I manually submit a record for approval. 

But if I submit the record for approval from a trigger I am getting the error

MANAGER_NOT_DEFINED, Manager undefined

I did not define the ( Next Automated Approver Determined By) since I dont want the manager to approve this , I want only the 2 related users defined in the approval step to be assigned. 

Any IDeas? 

Thanks 



 User-added image
Hi everyone,


I've been stuck on this a few days now and can't seem to find any decent tutorials online that can help either.

I'm looking to create a custom object that I will call 'Reseller' this custom object needs to behave just like a Parent account for example.

The part that I am finding particularly difficult is being able to display related opportunities and accounts on the Reseller page.

In an ideal world, I'd like to be able to look up a reseller and then view the accounts or opportunities that they are related to.

Imagine it to be an Account page, only called Reseller instead.

Any help or suggestions would be HUGELY appreciated, I haven't worked with custom objects at all before.

Thanks in advance,

Ash
Hello 

 I have 95% covergae in production , and I moving classes/triggers that have (97%) coverage in dev. 

Whan I deploy in production , I am getting the error 

Code Coverage Failure
Your organization's code coverage is 73%. You need at least 75% coverage to complete this deployment.

what am I missing here !?

Thanks