You need to sign in to do that
Don't have an account?
Admin User 3354
Error during deployment of test class.
Hello,
I am facing the following Error: " TestAttendanceUpdateTaxi.TestinsertAttendance(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, No Existing Campaign Product found, request you to generate it manually.: [] Class.TestAttendanceUpdateTaxi.TestinsertAttendance: line 53, column 1" during deplyment when i validate the following trigger.
Test Class:
@isTest
public class TestAttendanceUpdateTaxi
{
private static testMethod void TestinsertAttendance()
{
//Inserting Records for Company Obj(Accounts).
////Fetching Record Type for Company Obj
RecordType rt1 = [select id, Name from RecordType where SobjectType = 'Account' AND Name='Sherbet'];
Account account = new Account();
account.recordTypeId = rt1.id;
account.Name= 'Test Account';
insert account;
//Insering into Opportunity
Opportunity o=new Opportunity();
o.Name='Test2';
o.AccountId=account.Id;
o.CloseDate=date.today();
o.Order_Reference__c = 'test1212';
o.StageName='6 Signed deal';
insert o;
//Inserting Record for Taxi Obj
//Fetching Record Type for Taxi Obj
RecordType rt = [SELECT id, Name FROM RecordType WHERE SobjectType='Taxi__c' AND Name='Sherbet'];
Taxi__c OTaxi = new Taxi__c();
OTaxi.recordTypeId=rt.id;
OTaxi.Name = 'Tx912';
OTaxi.Company__c = account.id ;
OTaxi.Last_Attended_Date__c = System.today();
insert OTaxi;
//Retrive inserted Taxi
OTaxi = [select Name from Taxi__c where Id =: OTaxi.Id];
System.debug('Taxi Registration No :'+ OTaxi.Name);
//Inserting record for Attendance Object
Driver_Payment__c OAttendance = new Driver_Payment__c();
OAttendance.Campaign__c = o.id;
OAttendance.Company_Name__c = account.id;
OAttendance.Taxi_ID__c = OTaxi.id;
OAttendance.Attended_Date__c = System.today();
OAttendance.Update_current_receipt_campaign__c = True;
OAttendance.Update_current_Superside_Livery_Campaign__c = True;
// OAttendance.Update_current_Tip_seat_campaign__c = True;
insert OAttendance;
System.debug('Inserted values in Attendance obj');
//updating attendance
//Updating Values
OAttendance.Update_current_Tip_seat_campaign__c = True;
update OAttendance;
//Assert
Taxi__c ObjTaxi = [select Last_Attended_Date__c from Taxi__c where Name = 'Tx912' and Taxi__c.Company__c =: account.Id /*'001q000000JwBJT'*/ limit 1];
System.assertEquals(OAttendance.Attended_Date__c , ObjTaxi.Last_Attended_Date__c);
}
}
There are no validation rules on any object except opportunity.
Also I can't understand why it is asking me to create campaign product.
Urgent help is needed as my deployment is stuck because of single trigger.
Thanks.
I am facing the following Error: " TestAttendanceUpdateTaxi.TestinsertAttendance(), Details: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, No Existing Campaign Product found, request you to generate it manually.: [] Class.TestAttendanceUpdateTaxi.TestinsertAttendance: line 53, column 1" during deplyment when i validate the following trigger.
Test Class:
@isTest
public class TestAttendanceUpdateTaxi
{
private static testMethod void TestinsertAttendance()
{
//Inserting Records for Company Obj(Accounts).
////Fetching Record Type for Company Obj
RecordType rt1 = [select id, Name from RecordType where SobjectType = 'Account' AND Name='Sherbet'];
Account account = new Account();
account.recordTypeId = rt1.id;
account.Name= 'Test Account';
insert account;
//Insering into Opportunity
Opportunity o=new Opportunity();
o.Name='Test2';
o.AccountId=account.Id;
o.CloseDate=date.today();
o.Order_Reference__c = 'test1212';
o.StageName='6 Signed deal';
insert o;
//Inserting Record for Taxi Obj
//Fetching Record Type for Taxi Obj
RecordType rt = [SELECT id, Name FROM RecordType WHERE SobjectType='Taxi__c' AND Name='Sherbet'];
Taxi__c OTaxi = new Taxi__c();
OTaxi.recordTypeId=rt.id;
OTaxi.Name = 'Tx912';
OTaxi.Company__c = account.id ;
OTaxi.Last_Attended_Date__c = System.today();
insert OTaxi;
//Retrive inserted Taxi
OTaxi = [select Name from Taxi__c where Id =: OTaxi.Id];
System.debug('Taxi Registration No :'+ OTaxi.Name);
//Inserting record for Attendance Object
Driver_Payment__c OAttendance = new Driver_Payment__c();
OAttendance.Campaign__c = o.id;
OAttendance.Company_Name__c = account.id;
OAttendance.Taxi_ID__c = OTaxi.id;
OAttendance.Attended_Date__c = System.today();
OAttendance.Update_current_receipt_campaign__c = True;
OAttendance.Update_current_Superside_Livery_Campaign__c = True;
// OAttendance.Update_current_Tip_seat_campaign__c = True;
insert OAttendance;
System.debug('Inserted values in Attendance obj');
//updating attendance
//Updating Values
OAttendance.Update_current_Tip_seat_campaign__c = True;
update OAttendance;
//Assert
Taxi__c ObjTaxi = [select Last_Attended_Date__c from Taxi__c where Name = 'Tx912' and Taxi__c.Company__c =: account.Id /*'001q000000JwBJT'*/ limit 1];
System.assertEquals(OAttendance.Attended_Date__c , ObjTaxi.Last_Attended_Date__c);
}
}
There are no validation rules on any object except opportunity.
Also I can't understand why it is asking me to create campaign product.
Urgent help is needed as my deployment is stuck because of single trigger.
Thanks.
First identify in which object yo have validation rule with the error message "No Existing Campaign Product found" and update your test data in your test class to match the validation rule condition.