• sflearn
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 22
    Replies

my controller is pulling a list of app names(which are picklist values on a custom field) and displaying it on the page. Now the picklist values show as checkboxes fine but when I select Cool App 1 check box on the page, the input field doesn't show.....perhaps I need a getter or setter on the selectedApp in the controller?

 

 

    public List<SelectOption> getApps(){
        if(apps== null){
            apps= new List<SelectOption>();
            Schema.DescribeFieldResult appField = Schema.sObjectType.Lead.fields.Applications__c;
            Schema.PicklistEntry [] values = appField.getPickListValues();
            for(Schema.PicklistEntry value: values){
                apps.add(new SelectOption(value.getValue(), value.getLabel()));
            }
        }
        return apps;    
    }

              <apex:panelGrid columns="2">
                    <apex:outputLabel for="apps"><span class="required">* </span>My Apps:</apex:outputLabel>
                    <apex:outputPanel >
                        <apex:actionRegion >
                        <apex:selectCheckBoxes value="{!selectedApps}" required="true">
                            <apex:selectOptions value="{!apps}"/>
                             <apex:actionSupport event="onchange" rerender="appTypeDiv"/>
                        </apex:selectCheckBoxes>
                       </apex:actionRegion>
                    </apex:outputPanel>
                </apex:panelGrid>

 

 

                <apex:panelGrid columns="2">   

                <!-- input field code for Cool App2-->

                <!-- input field code for Cool App3-->

                    <apex:outputPanel id="appTypeDiv" rendered="{!apps= 'Cool App 1'}">
                     <apex:outputLabel for="appType"><span class="required">* </span> App Type:</apex:outputLabel>
                     <apex:inputField value="{!Lead.App_Type__c}" id="appType" required="true"/>
                    </apex:outputPanel>

                  </apex:panelGrid>
   

The before update trigger below passes trigger records  into the parentObjectMap. I am running various test methods and when i run my bulk tests to the parent object it says too many future calls.  I think my catch block is not bulified so every time there is more than 10 records that are bad , the future class is called to many time. how could i bulkify that? Eveything else works fine. basically, if the child items are incomplete i throw an error to the parent object

 

 

try{
    for(childObject: childObjectList){
      if(childObject.custom_field__c == null)

         parentObjectMap.get(childObject.ParentObjectId).addError('Incomplete child items');

      }
}

   if(test.isRunningTest())
   {
       throw new TestException('Exception');
    }
}

 

catch(Exception ex) {
FutureErrorlog.createExRec(ex.getMessage());
}
}

 

 

global class FutureErrorlog{
@future
public static void createExRec(string exceptionMessage){
Error_Log__c exceptionRec = new Error_Log__c(
Error_Message__c = exceptionMessage);
insert exceptionRec;
}
}

 

 

I am trying to pass coverage for my async handler below but can't see to catch the error. i have a before trigger that simply passes the message to the global class. This seems to work i write some code in an anoynous block..any thoughts?

    

my trigger class

catch (Exception ex){
          FutureCreateException.createExRecord(ex.getMessage());

 

Future class

global class FutureCreateException{
  @future
   public static void createExRecord(string exMessage){
         Error_Log__c exceptionRec = new Error_Log__c(Exception_Message__c = exMessage);
         insert exceptionRec
      }
}

 

when i run my test class I get the exception but it doesn;t insert it into my error_log__c object so my test class fails. again, when I used anoymous block it works

like this 

try{
Order__corder = [SELECT ID FROM Order__c where id='01uW000000HXBNPIA5''];
opp.id = '000000000000000000';
update opp;
}

catch (Exception ex){
FutureCreateException.createExRecord(ex.getMessage());
}


I am trying to assert unexpected exception when a before update trigger fires. I tried this in anonomyous block and my async class is fine and works but how come my assert keeps failing? do i need to wrap that in a try catch too? 

 

before update trigger calls this class


try{

 // do some logic
}
catch (Exception x){
FutureCreateException.createExRecord(x.getMessage());

 

Future class

global class FutureCreateException{
  @future
   public static void createExRecord(string exMessage){
         Error_Log__c exceptionRec = new Error_Log__c(Exception_Message__c = exMessage);
         Database.insert(exceptionRec,false);
      }
}

 

test method

test.starttest()

 Integer curELogCount= [SELECT COUNT() 

                                             FROM Error_Log__c];

 

Order order = [SELECT ID FROM Order

                          WHERE ID = '01pW00000004zmpIAA ];
order.id = '000000000000000000';
update order;

test.stoptest()

Integer afterELogCount= [SELECT COUNT() 
                                             FROM Error_Log__c];

 

  System.AssertEquals(curELogCount+1, afterELogCount);

 

 

 

 

 

if you have an adderror method in a before trigger, will it exist the entire batch if 1 record calls the adderror? if so, how can you partially process those records with an explicit database.update method

map should save us script limits

   try{
        for(Account a:aList){
               for(Contact c: cList){
                   if( c.custom_field__c == null 
                    || c.custom_field__c==null {
                       a.addError('missing contact info!);
                   }
               }      
            }
        }

        catch(System.Exception e){
            ex.setMessage('Something really bad!');
        }

i have an opportunity before trigger that works great but how do i keep it from firing when a new opportunitylineitem is added? it keeps changing a field on the opportunity causing it the opportunity to fire also there are some rollup fields on the opportunity and i think that is also the issue 

I'm trying to get my head around this new design pattern on wrapper classes. &nbsp;how does the controller know that the value from the selected <INPUTCHECKBOX> &nbsp;tag is true?Is it because since the inputCheckbox component automatically passes true through the standard component library? &nbsp;
if(cCon.selected == true)
&nbsp;
&nbsp;
public cContact(Contact c) {
con = c;
selected =
http://wiki.developerforce.com/page/Wrapper_Class
&nbsp;
&nbsp;</INPUTCHECKBOX>

When should I use apex:message vs apex:messages vs  apex:pageMessage and apex:pageMessages? I read the docs but its very confusing

Learning about properties and how come the output of my page is   'ConstructorValue' rather than 'ReplaceConstructorValue' when my setter is called right after the constructor initializes my message variable? Shouldn't message be set to 'ReplaceConstructorValue'?

 

 
public class myOrderTestController
{  
    public String message;
    public myOrderTestController()
    {
       //process constructor value
    }
    
    public void setMessage()
    {
      //  process ReplaceConstructorValue';    
    }   
    
    public String getMessage()
    {
  // return message
   }
}

my controller is pulling a list of app names(which are picklist values on a custom field) and displaying it on the page. Now the picklist values show as checkboxes fine but when I select Cool App 1 check box on the page, the input field doesn't show.....perhaps I need a getter or setter on the selectedApp in the controller?

 

 

    public List<SelectOption> getApps(){
        if(apps== null){
            apps= new List<SelectOption>();
            Schema.DescribeFieldResult appField = Schema.sObjectType.Lead.fields.Applications__c;
            Schema.PicklistEntry [] values = appField.getPickListValues();
            for(Schema.PicklistEntry value: values){
                apps.add(new SelectOption(value.getValue(), value.getLabel()));
            }
        }
        return apps;    
    }

              <apex:panelGrid columns="2">
                    <apex:outputLabel for="apps"><span class="required">* </span>My Apps:</apex:outputLabel>
                    <apex:outputPanel >
                        <apex:actionRegion >
                        <apex:selectCheckBoxes value="{!selectedApps}" required="true">
                            <apex:selectOptions value="{!apps}"/>
                             <apex:actionSupport event="onchange" rerender="appTypeDiv"/>
                        </apex:selectCheckBoxes>
                       </apex:actionRegion>
                    </apex:outputPanel>
                </apex:panelGrid>

 

 

                <apex:panelGrid columns="2">   

                <!-- input field code for Cool App2-->

                <!-- input field code for Cool App3-->

                    <apex:outputPanel id="appTypeDiv" rendered="{!apps= 'Cool App 1'}">
                     <apex:outputLabel for="appType"><span class="required">* </span> App Type:</apex:outputLabel>
                     <apex:inputField value="{!Lead.App_Type__c}" id="appType" required="true"/>
                    </apex:outputPanel>

                  </apex:panelGrid>
   

The before update trigger below passes trigger records  into the parentObjectMap. I am running various test methods and when i run my bulk tests to the parent object it says too many future calls.  I think my catch block is not bulified so every time there is more than 10 records that are bad , the future class is called to many time. how could i bulkify that? Eveything else works fine. basically, if the child items are incomplete i throw an error to the parent object

 

 

try{
    for(childObject: childObjectList){
      if(childObject.custom_field__c == null)

         parentObjectMap.get(childObject.ParentObjectId).addError('Incomplete child items');

      }
}

   if(test.isRunningTest())
   {
       throw new TestException('Exception');
    }
}

 

catch(Exception ex) {
FutureErrorlog.createExRec(ex.getMessage());
}
}

 

 

global class FutureErrorlog{
@future
public static void createExRec(string exceptionMessage){
Error_Log__c exceptionRec = new Error_Log__c(
Error_Message__c = exceptionMessage);
insert exceptionRec;
}
}

 

 

I am trying to pass coverage for my async handler below but can't see to catch the error. i have a before trigger that simply passes the message to the global class. This seems to work i write some code in an anoynous block..any thoughts?

    

my trigger class

catch (Exception ex){
          FutureCreateException.createExRecord(ex.getMessage());

 

Future class

global class FutureCreateException{
  @future
   public static void createExRecord(string exMessage){
         Error_Log__c exceptionRec = new Error_Log__c(Exception_Message__c = exMessage);
         insert exceptionRec
      }
}

 

when i run my test class I get the exception but it doesn;t insert it into my error_log__c object so my test class fails. again, when I used anoymous block it works

like this 

try{
Order__corder = [SELECT ID FROM Order__c where id='01uW000000HXBNPIA5''];
opp.id = '000000000000000000';
update opp;
}

catch (Exception ex){
FutureCreateException.createExRecord(ex.getMessage());
}

map should save us script limits

   try{
        for(Account a:aList){
               for(Contact c: cList){
                   if( c.custom_field__c == null 
                    || c.custom_field__c==null {
                       a.addError('missing contact info!);
                   }
               }      
            }
        }

        catch(System.Exception e){
            ex.setMessage('Something really bad!');
        }

When should I use apex:message vs apex:messages vs  apex:pageMessage and apex:pageMessages? I read the docs but its very confusing

Learning about properties and how come the output of my page is   'ConstructorValue' rather than 'ReplaceConstructorValue' when my setter is called right after the constructor initializes my message variable? Shouldn't message be set to 'ReplaceConstructorValue'?

 

 
public class myOrderTestController
{  
    public String message;
    public myOrderTestController()
    {
       //process constructor value
    }
    
    public void setMessage()
    {
      //  process ReplaceConstructorValue';    
    }   
    
    public String getMessage()
    {
  // return message
   }
}