You need to sign in to do that
Don't have an account?
Luke Higgins - RF
Deployment change set error on apex email trigger Class Name:MyProfilePageControllerTest
Deployment change set error on apex email trigger Class Name:MyProfilePageControllerTest Error Message:FIELD_CUSTOM_VALIDATION_EXCEPTION "Please enter First Name"
I've got an email trigger in a sandbox I'm trying to deploy into production.
Here's the apex:
Obviously I've just copied this from this person's post. I don't know anything about apex.
But here's the error I'm receiving while validating the inbound change set for this trigger.
Class Name: MyProfilePageControllerTest
Method Name: testSave
Error Message: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter First Name: []
Stack Trace: Class.MyProfilePageControllerTest.testSave: line 34, column 1
Can anyone help with this error?
I've got an email trigger in a sandbox I'm trying to deploy into production.
Here's the apex:
trigger EmailMessage on EmailMessage (after insert) {
List<Case> casesToAssign = new List<Case>();
AssignmentRule ar = [SELECT Id FROM AssignmentRule WHERE SObjectType = 'Case' AND Active = true LIMIT 1];
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.AssignmentRuleHeader.AssignmentRuleId = ar.Id;
for(EmailMessage e : Trigger.new) {
AssignmentRule ar = [SELECT Id FROM AssignmentRule WHERE SObjectType = 'Case' AND Active = true LIMIT 1];
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.AssignmentRuleHeader.AssignmentRuleId = ar.Id;
for(EmailMessage e : Trigger.new) {
if(e.Incoming) {
Case c = new Case(Id = e.ParentId);
c.setOptions(dmlOpts);
casesToAssign.add(c);
c.setOptions(dmlOpts);
casesToAssign.add(c);
}
}
update casesToAssign;
update casesToAssign;
}
Created by frontendloaderObviously I've just copied this from this person's post. I don't know anything about apex.
But here's the error I'm receiving while validating the inbound change set for this trigger.
Class Name: MyProfilePageControllerTest
Method Name: testSave
Error Message: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter First Name: []
Stack Trace: Class.MyProfilePageControllerTest.testSave: line 34, column 1
Can anyone help with this error?
All Answers
here was the original message.
Something kind of like this:
@isTest
private class TestEmailMessageT {
static testMethod void TestEmailMessageT(){
Case a = new Case();
insert a;
EmailMessage b = new EmailMessage();
b.ParentId = a.id;
b.incoming = true;
try{
insert b;
}
catch (DMLException e)
{
system.debug(e);
}
}
}
Basically you have to have something that triggers the trigger if that makes sense.
Once you have it ready, there is a run test button in the upper right corner of the developer console that will allow you to run it in the sandbox. After it runs, go back to your trigger and check the code coverage.
I created a new outbound change set and validated it in production but got the same error.
The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
But they do now.
Thank you so much for walking me through this step by step and sticking with me for a couple hours today. How do I tag all your answers as the best? :)