• dave_mwi
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
I have the following soql statement:

Select o.Id, (Select ContactId From OpportunityContactRoles) From Opportunity o

However, some of the opportunities don't have contact roles...so this query retrieves all of my opportunities with our without contact roles. I'm using the Force IDE along with the schema browser and this shows up as a two-columned table with one of the columns being an OpportunityContactRole object - titled 'OpportunityContactRoles' and no, trying OpportunityContactRoles != NULL in the main query didn't work.


So my question is, how do I only get the opportunities that only have associated opportunity contact roles?
I just started having problems with my Force IDE in Eclipse when I create new triggers.

The panel is not loading the Trigger objects after I specify a name for the trigger, and hence I cannot proceed with my trigger coding. This is a real roadblock right now. I've included output from the command line after launching my IDE and encoutering this issue:

Code:
ERROR [2008-03-11 16:23:22,442 {HH:mm:ss}] (—:additionalInitialize:–) - Unable to load trigger objects
com.salesforce.toolkit.remote.ToolkitConnectionException: UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService
        at com.salesforce.toolkit.utils.ToolkitExceptionUtils.handleConnectionException(Unknown Source)
        at com.salesforce.toolkit.remote.Connection.getTypes(Unknown Source)
        at com.salesforce.toolkit.remote.registries.DescribeObjectRegistry.loadDescribeCaches(Unknown Source)
        at com.salesforce.toolkit.remote.registries.DescribeObjectRegistry.getCachedDescribeSObjects(Unknown Source)
        at com.salesforce.toolkit.ui.wizards.components.ComponentController.getTriggerObjectNames(Unknown Source)
        at com.salesforce.toolkit.ui.wizards.components.apex.ApexTriggerWizardPage.additionalInitialize(Unknown Source)
        at com.salesforce.toolkit.ui.wizards.components.BaseComponentWizardPage.initialize(Unknown Source)
        at com.salesforce.toolkit.ui.wizards.components.BaseComponentWizardPage.createControl(Unknown Source)
        at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:170)
        at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:669)
        at org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1083)
        at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1142)
        at org.eclipse.jface.wizard.WizardDialog.access$2(WizardDialog.java:1139)
        at org.eclipse.jface.wizard.WizardDialog$4.run(WizardDialog.java:1128)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
        at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1126)
        at org.eclipse.ui.internal.dialogs.NewWizardSelectionPage.advanceToNextPageOrFinish(NewWizardSelectionPage.java:71)
        at org.eclipse.ui.internal.dialogs.NewWizardNewPage$1.doubleClick(NewWizardNewPage.java:355)
        at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:799)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
        at org.eclipse.core.runtime.Platform.run(Platform.java:863)
        at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
        at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:193)
        at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:797)
        at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1384)
        at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1173)
        at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:237)
        at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:234)
        at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:295)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1101)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3319)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
        at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
        at org.eclipse.jface.window.Window.open(Window.java:796)
        at org.eclipse.ui.actions.NewWizardAction.run(NewWizardAction.java:182)
        at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:123)
        at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:239)
        at org.eclipse.core.commands.Command.executeWithChecks(Command.java:475)
        at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:429)
        at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:165)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:821)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:879)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:568)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
        at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1423)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1100)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1125)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1110)
        at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1137)
        at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:663)
        at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2533)
        at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:679)
        at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1486)
        at org.eclipse.swt.widgets.Control.windowProc(Control.java:4234)
        at org.eclipse.swt.widgets.Display.windowProc(Display.java:3973)
        at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
        at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:5593)
        at org.eclipse.swt.widgets.Display.eventProc(Display.java:1192)
        at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
        at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1487)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2969)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
        at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:443)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1169)


 
Any suggestions would really help  
I'm stumped about rate limits in my Trigger. Here is the code:

Code:
trigger campaignAssociationLeadTrigger on Lead(after insert, after update){
 // Get the campaign object based on the hitbox identifier
 List<Campaign> camps = new Campaign[0];
 
 // Iterate through the 'new' list in the Trigger, which is Lead objects. This is for 'Update' of a Lead
 try
 {
  if(Trigger.isUpdate)
  {
   for(Lead l : Trigger.new)
   {
    
    // The only time we don't want to create a campaign or conversion is when
    // The old values match the incoming values. At least for now.
    boolean oldMatchSource = true;
    boolean oldMatchConversion = true;
    if(Trigger.oldMap.get(l.id) != null)
    {
     Lead oldLead = Trigger.oldMap.get(l.id);
     oldMatchSource = (l.Hitbox_Code__c != oldLead.Hitbox_Code__c);
     oldMatchConversion = (l.Conversion__c != oldLead.Conversion__c);
    }
    
    if(oldMatchSource && l.Hitbox_Code__c != null && l.Hitbox_Code__c != '')
    {
     // Get the campaing code by that name.
     try
     {
      camps.add([SELECT id FROM campaign WHERE name = :l.Hitbox_Code__c]);
     }
     catch(Exception e)
     {
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      String[] toAddresses = new String[] {'me@mydomain.com'}; 
      mail.setToAddresses(toAddresses);
      mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
      mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause()+'\n\nCode was: '+l.Hitbox_Code__c);
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
     }
     
     // Create a campaign member from the first in the list
     if(camps.size()>0)
     {
      CampaignMember cmp = new CampaignMember(LeadId=l.id,CampaignId=camps[0].id);
      // Insert
      insert cmp;
     }
    
    }
    
    if(oldMatchConversion && l.Conversion__c != null && l.Conversion__c != '')
    {
     
     // If there was a hitbox code, add it to the conversion.
     if(camps.size()>0)
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c, Campaign__c = camps[0].id);
      insert conv;
     }
     else
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c);
      insert conv;
     }
    }
   }
  } 
  else
  {
   // This is an Insert trigger
   for(Lead l : Trigger.new)
   {
    // If there is a lead source code continue to add a campaign.
    if(l.Hitbox_Code__c != null && l.Hitbox_Code__c != '')
    {
     // Get the campaing code by that name.
     try
     {
      camps.add([SELECT id FROM campaign WHERE name = :l.Hitbox_Code__c]);
     }
     catch(Exception e)
     {
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      String[] toAddresses = new String[] {'me@mydomain.com'}; 
      mail.setToAddresses(toAddresses);
      mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
      mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause()+'\n\nCode was: '+l.Hitbox_Code__c);
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
     }
     
     // Create a campaign member from the first in the list
     if(camps.size()>0)
     {
      CampaignMember cmp = new CampaignMember(LeadId=l.id,CampaignId=camps[0].id);
      // Insert
      insert cmp;
     }
    }
    // If the conversion is not empty, then create a conversion object
    if(l.Conversion__c != null && l.Conversion__c != '')
    {
     // If there was a hitbox code, add it to the conversion.
     if(camps.size()>0)
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c, Campaign__c = camps[0].id);
      insert conv;
     } 
     else
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c);
      insert conv;
     }
    }
   } 
  }
 }
 catch(Exception e)
 {
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  String[] toAddresses = new String[] {'me@mydomain.com'}; 
  mail.setToAddresses(toAddresses);
  mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
  mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause());
  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 }
}

 
I know the code might not be the 'soundest' but why am I exceding my limit at 21? What's happening now is that I have leads created now with incomplete campaign member or conversion object assocations. The rate can be exceeded at any one of the DML statements above...whichever happens to be 21...

If someone could point me in a good direction here or give me some good advice I would whole-heartedly appreciate it. Thanks.

- Dave

I am receiving this error when trying to save a trigger to my production SF account:

Code:
 Run test failure marker: resource '': 'System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, opportunityContactRoleUpdate: execution of BeforeInsert

 
Here is my trigger. I've tried it on after insert as well:

Code:
trigger opportunityContactRoleUpdate on Opportunity (before Insert, before Update)
{

 // Loop over the Opportunities in the 'new' list of the
 for(Opportunity o : Trigger.new)
 {
  // Here we need to do the contsraint check
  if((o.StageName == 'Closed Won (Recurring)' || o.StageName == 'Pilot (Recurring)') && o.Recurring_Opportunity__c=='Yes' && o.Probability>=90.0 && o.Client_Id__c==4944)
  {
  
   // We need yesterdays Date. First go to the start of the current Month just to be safe.
   // Then subtract one day.
   Date a = System.today();
   Date b = a.toStartOfMonth();
   Date c = b.addDays(-1);
   
   // Get the Opportunity that this one was created from using
   // the client id and a close date of before the first of last month
   // We are getting a limit of 1, to get the latest. It might not have been
   // From the last month per se, but the latest excluding this one.
   List<Opportunity> oldOpps = [SELECT id FROM opportunity WHERE Client_Id__c = :o.Client_Id__c AND closedate <= :c ORDER BY closedate DESC LIMIT 1];
   
   // Get any OpportunityContactRoles attached to the old Opportunity
   List<OpportunityContactRole> ocrs = [SELECT id, OpportunityId FROM OpportunityContactRole WHERE OpportunityId=:oldOpps[0].id];
   
   // Loop through any found OpportunityContactRole objects and set the OpportunityId
   // to the OpportunityId of the new Opportunity
   for(integer i=0; i<ocrs.size(); i++)
   {
    OpportunityContactRole new_ocr = new OpportunityContactRole(OpportunityId = o.id,ContactId = ocrs[i].ContactID,Role = ocrs[i].Role);
    insert new_ocr;
   }
  }
 }
}

 I've checked my profile permissions and I have 'Modify All' set...any reason why I shouldn't be able to create this new opportunityContactRole? I can't find anything about why I wouldn't with the 'Modify All' permissions set...

I have read several posts and done quite a bit of searching. I'm still having trouble. I have the following trigger:

Code:
trigger opportunityContactRoleUpdate on Opportunity (after Insert, after Update)
{

    for(Opportunity o : Trigger.new)
    {
        if((o.StageName == 'Closed Won (Recurring)' || o.StageName == 'Pilot (Recurring)') && o.Recurring_Opportunity__c=='Yes' && o.Probability>=90.0 && o.Client_Id__c==4944)
        {
            Date a = System.today();
            Date b = a.toStartOfMonth();
            Date c = b.addDays(-1);
           
            List<Opportunity> oldOpps = [SELECT id FROM opportunity WHERE Client_Id__c = :o.Client_Id__c AND closedate <= :c ORDER BY closedate DESC LIMIT 1];
           

            List<OpportunityContactRole> ocrs = [SELECT id, OpportunityId FROM OpportunityContactRole WHERE OpportunityId=:oldOpps[0].id];
           
            for(integer i=0; i<ocrs.size(); i++)
            {
                ocrs[i].OpportunityId = o.id;
            }
           
            if(!ocrs.isEmpty())
            {
                update ocrs;
            }
        }
    }
}

 For which I created an Apex Test class to get coverage on:

Code:
public class opportunityContactRoleUpdateTest {

 static testMethod void myTest()
 {
  Opportunity o = new Opportunity(name='Dave 1', stagename='My Stage 1');
  
  insert o;
  
  o.Name = 'Dave 1 Updated';
  o.Stagename = 'My Stage 1 Updated';
  
  update o;
 }

}

I created this based on another post - because the insertion and create of this opportunity would cause my trigger to fire, give me enough coverage.

I'm developing in Eclipse using the Force IDE. These are some of the problems I'm having.

1. I cannot save to the server more that the class definition of my Test class. The body of my class never saves to or gets to my production environment using the 'Save to Server' or 'Synchronize with Server' options in the Force IDE - although it runs, it never saves more than the inital class definition.

2. After I do get it on the server and run the test on it, how do I 'activate' the trigger (which by the way I can save to the server just fine...) Do I have to use the ant method to activate it, or can I do it with the Force IDE...I'm not having any luck finding the method to 'activate' the trigger.

3. I can 'run tests' on my small apex class that I created and it shows me 100% coverage...however it looks to me like it's telling me 100% of the testclass run, and not 100% of my trigger was covered...I would like to 'run all tests' on my apex class from SF, but as I said, i can't get it there...

I'm pretty stuck here. Any suggestions would help me out.

---

Updated: I downloaded and installed the latest Force IDE. I create a new workspace, and a new force.com project - synchronizing with our production env. Now I'm having additional errors when trying to run my test class. I get:

INVALID_OPERATION: Cannot specify both runAllTests and specific RunTests

This happens when I right click on the test class, select 'Force' and then run tests.




Message Edited by dave_mwi on 02-29-2008 12:58 PM

Message Edited by dave_mwi on 02-29-2008 01:00 PM
I've just created my sandbox and when I try to create a lead, I get this error on the next page after clickig the save button:

Data Not Available The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.

I've not been able to find anything about what this means.

I'm also getting a salesforce application error when I try to look at my user permissions while logged intot he sandbox - I thought the error might be related to this.

Thanks.
I'm stumped about rate limits in my Trigger. Here is the code:

Code:
trigger campaignAssociationLeadTrigger on Lead(after insert, after update){
 // Get the campaign object based on the hitbox identifier
 List<Campaign> camps = new Campaign[0];
 
 // Iterate through the 'new' list in the Trigger, which is Lead objects. This is for 'Update' of a Lead
 try
 {
  if(Trigger.isUpdate)
  {
   for(Lead l : Trigger.new)
   {
    
    // The only time we don't want to create a campaign or conversion is when
    // The old values match the incoming values. At least for now.
    boolean oldMatchSource = true;
    boolean oldMatchConversion = true;
    if(Trigger.oldMap.get(l.id) != null)
    {
     Lead oldLead = Trigger.oldMap.get(l.id);
     oldMatchSource = (l.Hitbox_Code__c != oldLead.Hitbox_Code__c);
     oldMatchConversion = (l.Conversion__c != oldLead.Conversion__c);
    }
    
    if(oldMatchSource && l.Hitbox_Code__c != null && l.Hitbox_Code__c != '')
    {
     // Get the campaing code by that name.
     try
     {
      camps.add([SELECT id FROM campaign WHERE name = :l.Hitbox_Code__c]);
     }
     catch(Exception e)
     {
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      String[] toAddresses = new String[] {'me@mydomain.com'}; 
      mail.setToAddresses(toAddresses);
      mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
      mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause()+'\n\nCode was: '+l.Hitbox_Code__c);
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
     }
     
     // Create a campaign member from the first in the list
     if(camps.size()>0)
     {
      CampaignMember cmp = new CampaignMember(LeadId=l.id,CampaignId=camps[0].id);
      // Insert
      insert cmp;
     }
    
    }
    
    if(oldMatchConversion && l.Conversion__c != null && l.Conversion__c != '')
    {
     
     // If there was a hitbox code, add it to the conversion.
     if(camps.size()>0)
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c, Campaign__c = camps[0].id);
      insert conv;
     }
     else
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c);
      insert conv;
     }
    }
   }
  } 
  else
  {
   // This is an Insert trigger
   for(Lead l : Trigger.new)
   {
    // If there is a lead source code continue to add a campaign.
    if(l.Hitbox_Code__c != null && l.Hitbox_Code__c != '')
    {
     // Get the campaing code by that name.
     try
     {
      camps.add([SELECT id FROM campaign WHERE name = :l.Hitbox_Code__c]);
     }
     catch(Exception e)
     {
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      String[] toAddresses = new String[] {'me@mydomain.com'}; 
      mail.setToAddresses(toAddresses);
      mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
      mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause()+'\n\nCode was: '+l.Hitbox_Code__c);
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); 
     }
     
     // Create a campaign member from the first in the list
     if(camps.size()>0)
     {
      CampaignMember cmp = new CampaignMember(LeadId=l.id,CampaignId=camps[0].id);
      // Insert
      insert cmp;
     }
    }
    // If the conversion is not empty, then create a conversion object
    if(l.Conversion__c != null && l.Conversion__c != '')
    {
     // If there was a hitbox code, add it to the conversion.
     if(camps.size()>0)
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c, Campaign__c = camps[0].id);
      insert conv;
     } 
     else
     {
      Conversion__c conv = new Conversion__c(Lead__c=l.id, Name=l.Conversion__c);
      insert conv;
     }
    }
   } 
  }
 }
 catch(Exception e)
 {
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  String[] toAddresses = new String[] {'me@mydomain.com'}; 
  mail.setToAddresses(toAddresses);
  mail.setSubject('Apex Exception in campaignAssociationContactTrigger');
  mail.setPlainTextBody(e.getMessage()+'\n\n'+e.getCause());
  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 }
}

 
I know the code might not be the 'soundest' but why am I exceding my limit at 21? What's happening now is that I have leads created now with incomplete campaign member or conversion object assocations. The rate can be exceeded at any one of the DML statements above...whichever happens to be 21...

If someone could point me in a good direction here or give me some good advice I would whole-heartedly appreciate it. Thanks.

- Dave

I have read several posts and done quite a bit of searching. I'm still having trouble. I have the following trigger:

Code:
trigger opportunityContactRoleUpdate on Opportunity (after Insert, after Update)
{

    for(Opportunity o : Trigger.new)
    {
        if((o.StageName == 'Closed Won (Recurring)' || o.StageName == 'Pilot (Recurring)') && o.Recurring_Opportunity__c=='Yes' && o.Probability>=90.0 && o.Client_Id__c==4944)
        {
            Date a = System.today();
            Date b = a.toStartOfMonth();
            Date c = b.addDays(-1);
           
            List<Opportunity> oldOpps = [SELECT id FROM opportunity WHERE Client_Id__c = :o.Client_Id__c AND closedate <= :c ORDER BY closedate DESC LIMIT 1];
           

            List<OpportunityContactRole> ocrs = [SELECT id, OpportunityId FROM OpportunityContactRole WHERE OpportunityId=:oldOpps[0].id];
           
            for(integer i=0; i<ocrs.size(); i++)
            {
                ocrs[i].OpportunityId = o.id;
            }
           
            if(!ocrs.isEmpty())
            {
                update ocrs;
            }
        }
    }
}

 For which I created an Apex Test class to get coverage on:

Code:
public class opportunityContactRoleUpdateTest {

 static testMethod void myTest()
 {
  Opportunity o = new Opportunity(name='Dave 1', stagename='My Stage 1');
  
  insert o;
  
  o.Name = 'Dave 1 Updated';
  o.Stagename = 'My Stage 1 Updated';
  
  update o;
 }

}

I created this based on another post - because the insertion and create of this opportunity would cause my trigger to fire, give me enough coverage.

I'm developing in Eclipse using the Force IDE. These are some of the problems I'm having.

1. I cannot save to the server more that the class definition of my Test class. The body of my class never saves to or gets to my production environment using the 'Save to Server' or 'Synchronize with Server' options in the Force IDE - although it runs, it never saves more than the inital class definition.

2. After I do get it on the server and run the test on it, how do I 'activate' the trigger (which by the way I can save to the server just fine...) Do I have to use the ant method to activate it, or can I do it with the Force IDE...I'm not having any luck finding the method to 'activate' the trigger.

3. I can 'run tests' on my small apex class that I created and it shows me 100% coverage...however it looks to me like it's telling me 100% of the testclass run, and not 100% of my trigger was covered...I would like to 'run all tests' on my apex class from SF, but as I said, i can't get it there...

I'm pretty stuck here. Any suggestions would help me out.

---

Updated: I downloaded and installed the latest Force IDE. I create a new workspace, and a new force.com project - synchronizing with our production env. Now I'm having additional errors when trying to run my test class. I get:

INVALID_OPERATION: Cannot specify both runAllTests and specific RunTests

This happens when I right click on the test class, select 'Force' and then run tests.




Message Edited by dave_mwi on 02-29-2008 12:58 PM

Message Edited by dave_mwi on 02-29-2008 01:00 PM

Hi

i hava a login class where i am creating a login and i am getting a session id.

public class Login_SupportForce {     public SoapBindingStub sfdc = null;     private String sessionID;  private String serverURL;     public void getLogin() throws ServiceException, ApiFault, RemoteException, MalformedURLException {                     SforceService service = new SforceServiceLocator();         sfdc = (SoapBindingStub)service.getSoap();

        System.out.println("Connecting to: " + service.getSoapAddress());              try{                                   // login             LoginResult loginResult = sfdc.login("psohal@njtransit.com", "nanki"); System.out.println("Logged in");                    // Reset the SOAP endpoint to the returned server URL             sfdc = (SoapBindingStub) new SforceServiceLocator().getSoap(new java.net. URL(loginResult.getServerUrl()));         // Create a new session header object         // add the session ID returned from the login             _SessionHeader sh = new _SessionHeader();             sh.setSessionId(loginResult.getSessionId());             sessionID = loginResult.getSessionId();             serverURL = loginResult.getServerUrl();         // Set the session header for subsequent call authentication             sfdc.setHeader(service.getServiceName().getNamespaceURI(),"SessionHeader", sh); System.out.println("get Session Id " + loginResult.getSessionId());  System.out.println("get user Id " + loginResult.getUserId()); System.out.println("get user Id " + loginResult.getServerUrl());   

     }catch(Exception e ){System.out.println("error in login class " + e);}               }     }

 

now i am calling the getLogin() method of  Login_Supportforce in a servlet. i am getting a session id.

Connecting to: https://www.salesforce.com/services/Soap/c/5.0 logged in get Session Id ho3Cs8qyOVw6XmaaVxAX1XzjdG0ItJFgFQVVQMwkbydr1ssrj_4yX.J4DayBR5WPA PIwpytqduBfrSnAV.SojTteaH1xyGi1 get user Id 00530000000ekzzAAA get user Id https://na1-api.salesforce.com/services/Soap/c/5.0 error in creating case Destination URL not reset. The URL returned from login mu st be set in the SforceService

  • May 13, 2005
  • Like
  • 0