You need to sign in to do that
Don't have an account?
RK
Problems Deploying New Trigger Via Eclipse Toolkit
Hey all,
With Apex now being available in EE, some new opportunities have opened to address requests from my users.
One of them is fairly straightforward - my users would like to see a contacts cellular number automatically populated on the task record - this would prevent them from needing to toggle back to the Contact record.
I played around in my DE account and got it working A-OK. All good.
However, when I go to deploy the code via Eclipse to my prod environment, I get the message about coverage:
"Copy_Contact_Cell_and_Mobile_To_Task_Record Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required"
I've read some of the other posts referring to the Code preview doc and the PDF overview of the, but my ignorant, non-programmer mind is struggling to make any headway in correcting the error.
I've enclosed my code below. Am I missing something easy? Or is this much more complicated in Production than it is in Dev.
Any guidance would be appreciated..
Thanks,
RK
With Apex now being available in EE, some new opportunities have opened to address requests from my users.
One of them is fairly straightforward - my users would like to see a contacts cellular number automatically populated on the task record - this would prevent them from needing to toggle back to the Contact record.
I played around in my DE account and got it working A-OK. All good.
However, when I go to deploy the code via Eclipse to my prod environment, I get the message about coverage:
"Copy_Contact_Cell_and_Mobile_To_Task_Record Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required
Test coverage of selected Apex Class and Trigger is 0%, at least 75% test coverage is required"
I've read some of the other posts referring to the Code preview doc and the PDF overview of the, but my ignorant, non-programmer mind is struggling to make any headway in correcting the error.
I've enclosed my code below. Am I missing something easy? Or is this much more complicated in Production than it is in Dev.
Any guidance would be appreciated..
Thanks,
RK
Code:
trigger Copy_Contact_Cell_and_Mobile_To_Task_Record on Task (after insert) { Id ContactIDOnTheTask; String contactCellNumber; String contactPhone2; for (Task TReadOnly : Trigger.new) if (TReadOnly.RecordTypeID == '0123000000005z2')//Limit Code to only FID Tasks {//IfOpening { Task t = [select Id, WhoID from Task where Id = :TReadOnly.Id limit 1]; //get ContactID ContactIDOnTheTask= t.WhoID; Contact[] phoneValueArray = [Select c.Id,c.mobilePhone,c.Phone_2__c from Contact c where c.Id = :ContactIDOnTheTask limit 1]; for(Integer i=0;i<phoneValueArray.size();i++) {//4 contactCellNumber = phoneValueArray[0].mobilePhone; //grab mobile number from array contactPhone2 = phoneValueArray[0].Phone_2__c; //grab phone2 number from array t.Mobile__c = contactCellNumber; //set mobile custom field on task to the contact mobile number t.Phone2__c = contactPhone2; //set phone2 custom field on task to contact phone2 number }//4 update t; } }//IfClosing }
I beleive that I need to create the test method that will ultimatley kick off my trigger code. From looking at some other examples, I beleive the general gist of the TestMethod is below.
However - how do I introduce this code? Is it entered as a separate class? Or do I append it to the code for my trigger?
It feels that if I introduce them separately that they will both fail.
Am I totally off base?
Sincerely,
CodeButcher.
--Code borrowed from MTBClimber. He wrote it much better, is not at all representative of what he/she produced and is only representative at the moment.
Message Edited by RK on 01-07-2008 06:00 AM
Message Edited by RK on 01-07-2008 11:24 PM
From what I can tell, the test method needs to be a separate class, and it and the trigger need to be validated simultaneously.
I'm still struggling to get appropiate coverage. I stil feel as if my trigger code is sound, just can't get the TestMethod code proper.
More as I let my frustration dissipate...
There is no code testing requirements for DE, which is why you didn't have that problem in that org.
Thanks for the reply. And I didn't think that it was being ignored. I realize that I'm asking what is a very basic to those who are experienced in general programming.
Unfortunately, I am not experienced, and my job will probably never allow me the opportunity to be (because of other priorities).
I'm glad to hear that there is a plan to document this a bit better...it will most likely help people like me.
I do have two requests as you are in the process of creating the documentation , and they are again very basic.
1. Am I barking up the right tree about the fact that the TestMethods need to be entered into a separate class and then uploaded/deployed at the same time as the trigger?
2. Would it be possible, as simplistic as it might be, to get sample of what the TestMethod would look like for the HelloWorld application, as contained on pages 56-58 in the cookbook? A simple example like that would help my non-programming mind visualize what is hapening a bit easier than some of the longer ones in the cookbook.
Thanks again,
RK
Message Edited by RK on 01-08-2008 12:01 PM
Thanks for passing it along...will see what I can take away from it.