• Bob.390672021994282E12
  • NEWBIE
  • 9 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 12
    Replies
I have two objects that I am trying to display on a screen. The parent works fine however the child records are not displaying anything. 
When I place an input value on the screen the input value doesnt even display. Am I missing something?
Yes there are records associated to the parent record already. 

Controller

public with sharing class ParentChild {

 private ApexPages.StandardController NormalSalesforceController {get; set;}
 public parent__c CurrentParentRecordId{get; set;}
 public List<child__c> childrecords {get; set;} // declare the list of child records. 
  
 public ParentChild(ApexPages.StandardController NormalSalesforceController){    

CurrentParentRecordId = [Select Id, Next_Step__c from Parent__c where id = :apexPages.currentPage().getParameters().get('id')];
}
 public List<child__c> getUserValue() {    
      List<child__c> UserValue= [SELECT Id, name, Field__c, Field_2__c, User__c, Parent__c FROM child__c WHERE Parent__c =:CurrentParentRecordId.id];
  return Uservalue;        
 }
}




<apex:page standardController="Parent__c" extensions="ParentChild" tabstyle="Account">
<apex:form >  
     <style>
            body .bPageBlock .pbBody .red .pbSubheader{
                background-color:#c00000;
            }
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#0000FF;     
            }
            body .bPageBlock .pbBody .green .pbSubheader{
                background-color:#7FFF00;
        }
      </style>       
        <apex:pageBlock title="Parent">  
        <apex:outputPanel styleClass="red" layout="block">
            <apex:pageBlockSection title="The parent Information" columns="3">            
            <apex:inputField value="{!Parent__c.Name}"/> 
            <apex:inputField value="{!Parent__c.Version_Number__c}"/> 
            <apex:inputField value="{!Parent__c.User__c}"/> 
       </apex:pageBlockSection>
        </apex:outputPanel> 
       </apex:pageblock>

        <apex:pageBlock title="Child">
        <apex:outputPanel styleClass="blue" layout="block">
        <apex:pageBlockSection title="The child Information" columns="3">     
        <apex:pageBlockTable value="{!Uservalue}" var="Child">
            <apex:inputField value="{!Child.Name}" />
              </apex:pageBlockTable>
          </apex:pageBlockSection>
          
         </apex:outputPanel>
    </apex:pageBlock>
        
    
</apex:form>
</apex:page>
I have two objects that I am trying to display on a screen. The parent works fine however the child records are not displaying anything. 
When I place an input value on the screen the input value doesnt even display. Am I missing something?
Yes there are records associated to the parent record already. 

Controller

public with sharing class ParentChild {

 private ApexPages.StandardController NormalSalesforceController {get; set;}
 public parent__c CurrentParentRecordId{get; set;}
 public List<child__c> childrecords {get; set;} // declare the list of child records. 
  
 public ParentChild(ApexPages.StandardController NormalSalesforceController){    

CurrentParentRecordId = [Select Id, Next_Step__c from Parent__c where id = :apexPages.currentPage().getParameters().get('id')];
}
 public List<child__c> getUserValue() {    
      List<child__c> UserValue= [SELECT Id, name, Field__c, Field_2__c, User__c, Parent__c FROM child__c WHERE Parent__c =:CurrentParentRecordId.id];
  return Uservalue;        
 }
}




<apex:page standardController="Parent__c" extensions="ParentChild" tabstyle="Account">
<apex:form >  
     <style>
            body .bPageBlock .pbBody .red .pbSubheader{
                background-color:#c00000;
            }
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#0000FF;     
            }
            body .bPageBlock .pbBody .green .pbSubheader{
                background-color:#7FFF00;
        }
      </style>       
        <apex:pageBlock title="Parent">  
        <apex:outputPanel styleClass="red" layout="block">
            <apex:pageBlockSection title="The parent Information" columns="3">            
            <apex:inputField value="{!Parent__c.Name}"/> 
            <apex:inputField value="{!Parent__c.Version_Number__c}"/> 
            <apex:inputField value="{!Parent__c.User__c}"/> 
       </apex:pageBlockSection>
        </apex:outputPanel> 
       </apex:pageblock>

        <apex:pageBlock title="Child">
        <apex:outputPanel styleClass="blue" layout="block">
        <apex:pageBlockSection title="The child Information" columns="3">     
        <apex:pageBlockTable value="{!Uservalue}" var="Child">
            <apex:inputField value="{!Child.Name}" />
              </apex:pageBlockTable>
          </apex:pageBlockSection>
          
         </apex:outputPanel>
    </apex:pageBlock>
        
    
</apex:form>
</apex:page>
I wanted to create a list view button, that will update all of the status that the users selects on the list view screen. (Salesforce Declarative Screen. )

When running the custom button I am getting the below error. 

System.UnexpectedException: Cannot add() on a class java.util.Arrays$ArrayList
Error is in expression '{!SubmitAllRequests}' in component <apex:page> in page submitall: External entry point

Is there anyway to do this without using JavaScript? Or having the records on a screen. The end result will be that whatever the user selects if conditions are met on the records will update the records accordingly. I am assuming based on the error that Salesforce doesnt allow add to their array class. Anythoughts on how to get around this? 




public with sharing class SubmitAllButton{

    Id CurrentUserID = UserInfo.GetUserID();
     
    set<id> UserSelect= new set<id>();
    
    private ApexPages.StandardSetController standardController;

    public SubmitAllButton(ApexPages.StandardSetController standardController)
    {
        this.standardController = standardController;
    }
     
    public PageReference SubmitAllRequests() {
 
       List<Object__c> Newrecordss= (List<Object__c>) standardController.getSelected();
       
       for(Object__c newrecords: Newrecordss)
        {
            UserStartDates.add(newrecords.id);
            system.debug('UserStartDates' + UserStartDates);
        }   
           
           
         for (Object__c UnSubmittedRequests: [SELECT Id, Next_Step__c, CreatedById, Attachement__c   FROM Object__c WHERE id=: UserSelect
         and CreatedById =: CurrentUserID  ])
             {
                
             
                if (UnSubmittedRequests.Next_Step__c == null && UnSubmittedRequests.Attachement__c != True){
                
                system.debug('UnSubmittedRequests' + UnSubmittedRequests);
                
                Object__c NewRecords = new Object__c ();
                
                
                NewRecords.id = UnSubmittedRequests.id;
                NewRecords.Next_Step__c = 'Request Review';
        
                 Newrecordss.add(NewRecords);   // this is where the error occurs. 
                  
                 
                }
                
                }
                
                
           
               update Newrecordss;
             
                
                return redirectToList();
                 
             }
             
            public PageReference redirectToList()  {
            Schema.DescribeSObjectResult result = ADR__c.SObjectType.getDescribe();
            PageReference pageRef = new PageReference('/' + result.getKeyPrefix());
            pageRef.setRedirect(true);
            return pageRef;
            
            }
            
             }




The page isnt doing anything except call the method to update

<apex:page standardController="Object__c" extensions="SubmitAllButton" recordSetVar="selected" action="{!SubmitAllRequests}">

</apex:page>
I was trying to figure out how to use value of in Salesforce. I want to grab the number of string on a field. 

parent = [select id, Name, version_number__c, Text_Field__c from Parent__c where id = :parent.id];

         newParent = parent.clone(false, true);

newparent.Text_Field__c =  valueOf(parent); // doesnt work.I would think that it would bring back the number of chars. 

                 insert newParent;


public static Integer valueOf(String toInteger){
Integer myInt = Integer.valueOf('123');
return myInt;
}


I have a method and a constructor. I know how to call a method but not a constructor. I would think that it would be like the below. Any suggestions? I want to place my generaterandomstring into my object name. Everytime the record saved it would insert the logic for the constructor in the name

public PageReference PCR() {

         Object__c newObject;
        
         object = [select id, Name, number__c from Object__cwhere id = :object.id];

    //     newObject.name =  RandomNumbersMethod();
         newObject.name = generateRandomString();
                 insert newObject;


}

My Method

public double RandomNumbersMethod()
{
return Math.random() * 10;
}

My Constructor 

public String generateRandomString(Integer len) {
 
    final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
    String randStr = '';

    while (randStr.length() < len) {
       Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 62);
       randStr += chars.substring(idx, idx+1);
    }
    return randStr;
  
}
Hello,

I am having an issue with my test class adderror on a trigger.

trigger Validation on ObjectA (before update) {
 
        for(ObjectA lstVAdd :  trigger.new){   

            if(lstVAdd.Supplier__c==null && lstVAdd.Status__c=='Closed' && lstVAdd.Comments__c ==null){
        Trigger.new[0].Supplier.addError(My Message);
           
                       }
        }
    }

Thank you
I have two objects that I am trying to display on a screen. The parent works fine however the child records are not displaying anything. 
When I place an input value on the screen the input value doesnt even display. Am I missing something?
Yes there are records associated to the parent record already. 

Controller

public with sharing class ParentChild {

 private ApexPages.StandardController NormalSalesforceController {get; set;}
 public parent__c CurrentParentRecordId{get; set;}
 public List<child__c> childrecords {get; set;} // declare the list of child records. 
  
 public ParentChild(ApexPages.StandardController NormalSalesforceController){    

CurrentParentRecordId = [Select Id, Next_Step__c from Parent__c where id = :apexPages.currentPage().getParameters().get('id')];
}
 public List<child__c> getUserValue() {    
      List<child__c> UserValue= [SELECT Id, name, Field__c, Field_2__c, User__c, Parent__c FROM child__c WHERE Parent__c =:CurrentParentRecordId.id];
  return Uservalue;        
 }
}




<apex:page standardController="Parent__c" extensions="ParentChild" tabstyle="Account">
<apex:form >  
     <style>
            body .bPageBlock .pbBody .red .pbSubheader{
                background-color:#c00000;
            }
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#0000FF;     
            }
            body .bPageBlock .pbBody .green .pbSubheader{
                background-color:#7FFF00;
        }
      </style>       
        <apex:pageBlock title="Parent">  
        <apex:outputPanel styleClass="red" layout="block">
            <apex:pageBlockSection title="The parent Information" columns="3">            
            <apex:inputField value="{!Parent__c.Name}"/> 
            <apex:inputField value="{!Parent__c.Version_Number__c}"/> 
            <apex:inputField value="{!Parent__c.User__c}"/> 
       </apex:pageBlockSection>
        </apex:outputPanel> 
       </apex:pageblock>

        <apex:pageBlock title="Child">
        <apex:outputPanel styleClass="blue" layout="block">
        <apex:pageBlockSection title="The child Information" columns="3">     
        <apex:pageBlockTable value="{!Uservalue}" var="Child">
            <apex:inputField value="{!Child.Name}" />
              </apex:pageBlockTable>
          </apex:pageBlockSection>
          
         </apex:outputPanel>
    </apex:pageBlock>
        
    
</apex:form>
</apex:page>
I wanted to create a list view button, that will update all of the status that the users selects on the list view screen. (Salesforce Declarative Screen. )

When running the custom button I am getting the below error. 

System.UnexpectedException: Cannot add() on a class java.util.Arrays$ArrayList
Error is in expression '{!SubmitAllRequests}' in component <apex:page> in page submitall: External entry point

Is there anyway to do this without using JavaScript? Or having the records on a screen. The end result will be that whatever the user selects if conditions are met on the records will update the records accordingly. I am assuming based on the error that Salesforce doesnt allow add to their array class. Anythoughts on how to get around this? 




public with sharing class SubmitAllButton{

    Id CurrentUserID = UserInfo.GetUserID();
     
    set<id> UserSelect= new set<id>();
    
    private ApexPages.StandardSetController standardController;

    public SubmitAllButton(ApexPages.StandardSetController standardController)
    {
        this.standardController = standardController;
    }
     
    public PageReference SubmitAllRequests() {
 
       List<Object__c> Newrecordss= (List<Object__c>) standardController.getSelected();
       
       for(Object__c newrecords: Newrecordss)
        {
            UserStartDates.add(newrecords.id);
            system.debug('UserStartDates' + UserStartDates);
        }   
           
           
         for (Object__c UnSubmittedRequests: [SELECT Id, Next_Step__c, CreatedById, Attachement__c   FROM Object__c WHERE id=: UserSelect
         and CreatedById =: CurrentUserID  ])
             {
                
             
                if (UnSubmittedRequests.Next_Step__c == null && UnSubmittedRequests.Attachement__c != True){
                
                system.debug('UnSubmittedRequests' + UnSubmittedRequests);
                
                Object__c NewRecords = new Object__c ();
                
                
                NewRecords.id = UnSubmittedRequests.id;
                NewRecords.Next_Step__c = 'Request Review';
        
                 Newrecordss.add(NewRecords);   // this is where the error occurs. 
                  
                 
                }
                
                }
                
                
           
               update Newrecordss;
             
                
                return redirectToList();
                 
             }
             
            public PageReference redirectToList()  {
            Schema.DescribeSObjectResult result = ADR__c.SObjectType.getDescribe();
            PageReference pageRef = new PageReference('/' + result.getKeyPrefix());
            pageRef.setRedirect(true);
            return pageRef;
            
            }
            
             }




The page isnt doing anything except call the method to update

<apex:page standardController="Object__c" extensions="SubmitAllButton" recordSetVar="selected" action="{!SubmitAllRequests}">

</apex:page>
I was trying to figure out how to use value of in Salesforce. I want to grab the number of string on a field. 

parent = [select id, Name, version_number__c, Text_Field__c from Parent__c where id = :parent.id];

         newParent = parent.clone(false, true);

newparent.Text_Field__c =  valueOf(parent); // doesnt work.I would think that it would bring back the number of chars. 

                 insert newParent;


public static Integer valueOf(String toInteger){
Integer myInt = Integer.valueOf('123');
return myInt;
}


I have a method and a constructor. I know how to call a method but not a constructor. I would think that it would be like the below. Any suggestions? I want to place my generaterandomstring into my object name. Everytime the record saved it would insert the logic for the constructor in the name

public PageReference PCR() {

         Object__c newObject;
        
         object = [select id, Name, number__c from Object__cwhere id = :object.id];

    //     newObject.name =  RandomNumbersMethod();
         newObject.name = generateRandomString();
                 insert newObject;


}

My Method

public double RandomNumbersMethod()
{
return Math.random() * 10;
}

My Constructor 

public String generateRandomString(Integer len) {
 
    final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
    String randStr = '';

    while (randStr.length() < len) {
       Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), 62);
       randStr += chars.substring(idx, idx+1);
    }
    return randStr;
  
}
Hello,

I am having an issue with my test class adderror on a trigger.

trigger Validation on ObjectA (before update) {
 
        for(ObjectA lstVAdd :  trigger.new){   

            if(lstVAdd.Supplier__c==null && lstVAdd.Status__c=='Closed' && lstVAdd.Comments__c ==null){
        Trigger.new[0].Supplier.addError(My Message);
           
                       }
        }
    }

Thank you
hi :) im building an visualforce page with a dinamic grid and im having trouble to pull the information there..
The table will only need information from one object but imy problem is the table format
should be like this
                       Colum1|colum2
              total
Name1   X          X             X 
Name2   X          X             X

so name1 and name 2 will be dinamic as the column 1 and column 2 and X will be values (everything is stored in one object)
im struggling to see how i build this in visualforce.
thanks
I'm trying to write test cases for my APEX code.I searched  the Apex documentation and  the Apex discussion board but did not find solution. I am getting two errors. I tried  but unfortunately not getting the required output. Let me know where i am getting error.  I had written the same code in the trigger without using Apex class it was working perfect. But since i need to deploy the trigger i started writing Apex class which gives me these errors.
Thanks in advance for the solution.
 
 
This is what i am trying to accomplish.
 
When ever a new custom object(Client)  is created or updated i need to update few fields accordingly.
 
 
And the errors are at line 35 and 54
 
Errrors
1)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
2)  System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClientUpdates: execution of AfterInsert
caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Class.ClientApex.afterinsertupdate: line 69, column 1
Trigger.ClientUpdates: line 19, column 1
 
 


Message Edited by renu on 07-09-2008 02:20 PM
  • July 09, 2008
  • Like
  • 1