• Colin Loretz
  • NEWBIE
  • 5 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 27
    Questions
  • 45
    Replies
Howdy all,

I've implemented dependent selectLists in the interface below. The issue I'm having is that the lists only work when only 1 set exists. IE: 1 row for time entry in this case. When I add a row to the interface, it creates a new timeEntry instance and the selectLists in the bottom-most row work properly, but any above that do not work.

Is there a way to dynamically rerender a row in a table or some VF component? Ideally, each row or each outputPanel would have a different ID but I can't seem to set the rerender="" attribute dynamically.

Code:
<apex:actionRegion >
<apex:selectList value="{!selectedProject}" size="1">
<apex:selectOptions value="{!ProjectOptions}" />
<apex:actionSupport event="onchange" rerender="mondayTask" status="loading" />
</apex:selectList>
</apex:actionRegion>                  

<apex:outputPanel id="mondayTask">
<apex:selectList value="{!taskId}" size="1" multiselect="false">
<apex:selectOptions value="{!taskItems}"/>
</apex:selectList>
</apex:outputPanel>




Here is the code for the VF section:
Code:
<apex:outputPanel id="mondayTable"> 

 <apex:form >
 <table cellpadding = "0" cellspacing = "0">
  <tr class = "header">
        <td>Projects</td>
        <td>Tasks</td>
        <td>Description</td>
        <td width = "50">Time</td>
       </tr>
  <apex:repeat value="{!mondayTime}" var="t">
 <tr>
  <td>
   <apex:actionRegion >
          <apex:selectList value="{!selectedProject}" size="1">
           <apex:selectOptions value="{!ProjectOptions}" />
     <apex:actionSupport event="onchange" rerender="mondayTask" status="loading" />
          </apex:selectList>
         </apex:actionRegion>                  
        </td>
        <td>
   <apex:outputPanel id="mondayTask">
          <apex:selectList value="{!taskId}" size="1" multiselect="false">
         <apex:selectOptions value="{!taskItems}"/>
       </apex:selectList>
         </apex:outputPanel>
        </td>
  <td><apex:inputText value="{!t.description}" /></td>
  <td><apex:inputText value="{!t.hours}" /></td>
 </tr>
  </apex:repeat>
  <tr>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td>&nbsp;</td>
   <td><apex:commandButton action="{!addEntry}" value="add row" rerender="mondayTable" status="loading"/></td>
   <td><apex:commandButton action="{!saveMondayTime}" value="save" /></td>
  </tr>
 </table>
 </apex:form>
 </apex:outputPanel>

 



I have a VF page with Controller Extension that very much resembles the example at http://wiki.apexdevnet.com/index.php/Wrapper_Class.  I had it all working great as it resembles that class.

I received a new requirement to add a String field into the wrapper and to add an inputText field onto the VF page.  So I added a new "public String problemDescription {get; set;}"  property into the wrapper class.  I then added an inputText field with a value attribute of that field, allowing the user to enter a value, process the records and use that input value in the Apex method.

For some reason, that field in the wrapper class is not picking up the value entered into the VF page.  If I hardcode a value as a default in the wrapper class constructor, that value will appear in my VF page.  However, if I overwrite that value in the page, the controller will not pick up on the new value.  It only uses the initial value.

The strange thing is that I have an inputCheckbox on my page bound to the selected property of the wrapper class and the controller picks up the value set on the page.  For some reason, it won't pickup my new value.  Ideas?

I can post the code if my explanation doesn't make sense, but I thought I'd keep it as simple as possible and ask people to start with that example on the wiki and try to add a String to the wrapper class and get the controller to read the values submitted from the page.
My objects are:

Object: Partner_Sent__c (object used for Many-to-Many)
Fields: CVB_Partner__c (Lookup to CVB_Partner__c object), Opportunity__c (Lookup to Opportunity object)

Object: Opportunity
Fields: Id, Name, Partner_Selected__c (Lookup to CVB_Partner__c)

Object: CVB_Partner__c
Fields: Id, Name

I want to do a query that gives me all CVB_Partner__c objects with the related Partner_Sent__c where the Partner_Selected__c is equal to the parent partner.

The code is much easier to understand:
Code:
Select Id, Name, (Select Id, Name, Opportunity__r.Partner_Selected__c from Partner_Sent__c where Opportunity__r.Partner_Selected__c = CVB_Partner__r.Id) from CVB_Partner__c

Unfortunately, I'm getting an error that states CVB_Partner__r.Id is not a valid field.

Am I doing something wrong or is this even possible?

Thanks!
 



I created unit tests for triggers and classes.

To view test coverage:

Eclipse -> Project- > src -> unpackaged -> classes -> Force.com -> run tests.
Under Failures and warnings and under general warnings it was showing 64% completed but 75 % test coverage is required.
Then I added one more test in a class as I am trying to reach for at least 85% test coverage but now when I right click to run tests I am seeing few failures and warnings but not seeing the the general warnings tab as before.

What does it mean? How can I see what percentage I have covered?




thanks,
kathyani
Code:
partnerResults = [Select Id, Name, 
(Select Id, Name, Opportunity__c, Opportunity__r.StageName from Partners_Sent__r
where Opportunity__c != null AND Opportunity__r.CloseDate = THIS_YEAR)
from CVB_Partner__c where Id in :partnerList];

 
I'm having an issue writing this dynamically. I would like to do so and substitute THIS_YEAR with a date picklist. However, when I write it as a query String, I get an error from the colon (:) in front of partnerList.

How might I do an 'IN' statement within a dynamic apex query?

Thanks.

Colin
Hey everyone,

I'm trying to build a tree component and am able to go down two levels but I'm not sure how (or if) it would be possible to continue adding levels.


I'm already building the above tree with the following code:
Controller:
public ProjectTask__c [] getTasks()
 {
  return [Select Id, Name, (Select Id, Name from Tasks__r)  from ProjectTask__c where Project__c = :projectId];
 }

 
VF Page:
<ul id ="tree" class="treeview">
 <apex:repeat value="{!tasks}" var="t">
  <li><span class = "file"><a href = "/{!t.id}">{!t.name}</a></span>
   <ul>
    <apex:repeat value="{!t.Tasks__r}" var="st">
     <li><span class = "file"><a href = "/{!st.Id}" />{!st.name}</a></span></li>
    </apex:repeat>
   </ul>
  </li>
 </apex:repeat>
</ul>

 If I have any items below 1.1 or 2.1, such as 1.1.1, 1.1.1.1, etc. what would be the best way to build a list of this nature?

Thanks,
Colin


When creating products in Salesforce, I have the need to create products with prices of up to 4 decimal places. IE: $0.0085

When that value is entered, the record is saved as $0.00. Our organization is setup to handle up to 4 decimal places in values. It does not even attempt to round the value to $0.01, it just drops the last two decimals.

As a test, I created my own Product and Pricebook objects, entered the price of $0.0085 in a currency field and the value is maintained perfectly. I would prefer to keep everything in the standard Products object because of the existing functionality that exists for them.

Has anyone else encountered this or know a work around?
We have a managed package containing a custom object with three record types.  Pre-Winter '09 it worked fine; now it won't install in other orgs, and I'm hoping someone can help me understand what has changed.

Symptoms:

1.  In the dev org, doing a "Run all Tests" reports 0 failures.

2.  If I take the managed package install link to another org and install, I get a bunch of unit test failures like this:

ut_calculations_modelvalidator.SimplestTestCase()Apex Classes(01p800000008jBO)
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, record type missing for: Support Program
(ENT_2)
;


Here's the source code for this test:

Code:
    static testMethod void SimplestTestCase() 
    {
        ENT_2__Support_Program__c sp = new ENT_2__Support_Program__c( 
             Name='TestSP',
             P1__c = 'xyz'
             );
        insert sp;
    }


3.  I thought maybe Winter '09 wanted me to specify a RecordTypeId explicitly, so I tried several variations on this:

Code:
    static testMethod void SimplestTestCase() 
    {
        ENT_2__Support_Program__c sp = new ENT_2__Support_Program__c( 
             Name='TestSP',
             P1__c = 'xyz'
             );
        sp.RecordTypeId = '012300000009x0G';
        insert sp;
    }

 
Again, the dev org's "Run all Tests" has no problem with this.  (That id is a valid record type for the dev org's ENT_2__Support_Program__c object.)  But rebuilding the package and attempting an install in any other org gives this error message:

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: id value not valid for the users profile: 012300000009x0GAAQ: [RecordTypeId]
(ENT_2)

Any idea what I am doing wrong?
Is there a way to read some values from a database and to generate a graphic diagram ?
I want to code a function, when a user goes over a link, the user gets information....like:
 
<- try a mouseover over the image 'smart people', you will see information and average (stars)...
 
 
Thank you very much!
 
Hi All,

I am creating a customize version of new lead page using Visualforce and I want to add Ajax which allows users to edit the field by directly double clicking on it. They do not need to click on "edit" button to re-load the entire page in edit mode..

Please suggest how I should start implementing Ajax with visualforce pages?

Any help in solving this problem would be highly appreciated.

Thank You,
Vishal

I'm having an issue with the data from a map being truncated.

I have a map consisting of:

Code:
Map<ID, CVB_Contact__c> m = new Map<Id, CVB_Contact__c>();

Everything works fine when I run some logic and add records to the map, I can see in my log that the data is being added to the map. However, if I try to output the map to the log file I get:
Code:
{Id:{record}, Id:{record}, Id:{record}, Id:{record}, 
Id:{record}, Id:{record}, Id:{record}, Id:{record}, Id:{record}, Id:{record}, ...}

Basically, it's truncating it after 10 map records.

I'm passing this map to a php script using an external callout and need to fix the truncation. Is there a limit to the size of a map? If so, what other options do I have?

I have tried sending the map in both GET and POST but neither affect the truncation as I can see that it is truncated in the log, before I even send it.
 
Thanks




Message Edited by Colin Loretz on 08-25-2008 09:38 AM
When using the time shortcuts, I'm having a hard time figuring out which day of the week a SalesForce week actually starts on. Is it Monday or Sunday?
 

I wrote the following code (replaced object/field names for simplicity) to handle rollup summary fields in Apex. It works pretty well but I frequently get errors when operating on bulk records or if no records exist (out of bounds, etc).

ParentObject__c :has_many Objects__c

Can anyone provide input as to whether or not I'm handling this type of task properly?

Code:
trigger rollupTrigger on Object__c (after insert, after update, after delete) {
    
    double totalSum = 0;
  
    Object__c myObjects = trigger.new;
    
    if(Trigger.isUpdate || Trigger.isInsert)
    {
            for(Object__c object : myObjects) //assume more than 1 record in trigger.new
            {
              for(ParentObject__c parent : [select Id, Name from ParentObject__c where Id = :object.Parent_Object__c]) //get the parent object
              {
                for(Object__c childObject : [select Id, Name, Number__c where Parent_Object__c = :parent.Id]) //get all the objects that belong to the parent object
                {
                  totalSum += childObject.Number__c;   //sum the field of choice
                }
                parent.Total__c = totalSum;   //set the total in the parent
                update parent                       // update the parent
              }
            }
    }
    else if(Trigger.isDelete)
    {
        Object__c [] oldObjects = Trigger.old;
        
      for(Object__c oldObject :oldObjects)    //assume deletion of more than 1 record
      {
        for (ParentObject__c parentObject : [select id, Name, Number__c, Total__c where Id = :oldObject.Parent_Object__c]) //get the parent object(s)
        {
          for (Object__c childObject : [select id, Name, Number__c from Object__c where Parent_Object__c = :parentObject.id])   //get the records that belong to the parent
          {
             totalSum += childObject.Number__c;  //sum the fields after a record has been deleted
          }
            parentObject.Total__c = totalSum;   //set new total in parent
            update parentObject;                      //update parent
        }   
      } //end oldObject for loop
    } //end else if
    
} //end trigger

Thanks!