You need to sign in to do that
Don't have an account?
anketha
Flow error while executing a test class
Hi,
When I run the below test class, I receive flow related error:
Method in the class:
static testMethod void rqiTest(){
DW_oData_vw_sf_Units__x mockedRequest = new DW_oData_vw_sf_Units__x(fuel__c=true,VIN__c='ABC123');
ExternalQueryHandler.mockedObject.add(mockedRequest);
Date d=date.today()+2;
RecordType RemarketingRTid = [Select id from RecordType where SobjectType='Account' and Name='Remarketing Venue'];
RecordType OppRTid = [Select id from RecordType where SobjectType='Opportunity' and name='FMS - Standard'];
Account a= NEW Account(Name='Test', Phone='12345678',RecordTypeId=RemarketingRTid.id);
insert a;
Contact c = NEW Contact(FirstName='test',LastName='Last',AccountId=a.id);
insert c;
Opportunity o= NEW Opportunity(Name='Test',AccountId=a.id,Type='Renewal',CloseDate=d,StageName='Proposal Presented',RecordTypeId=OppRTid.id);
insert o;
Remarketing_Quote__c rq = NEW Remarketing_Quote__c(Name='Test rq',Sales_Contact__c=c.id,Status__c='Opened',Account__c=a.id,Opportunity__c=o.id);
insert rq;
Remarketing_Quote_Item__c rqi = NEW Remarketing_Quote_Item__c(Remarketing_Quote__c=rq.id,fuel__c=false,VIN__c='ABC123',Status__c='Opened',Remarketing_Venue__c=a.id);
insert rqi;
LIST<Async_Request__c> newAR = NEW LIST<Async_Request__c>();
LIST<String> fields = NEW LIST<String>{'ID','VIN__c','OWNER__c','Lease__c','Fuel__c','Telematics__c','Maintenance__c'};
String whereClause = 'WHERE VIN__c = \'ABC123\'';
String ordering;
integer lim;
Test.startTest();
LIST<DW_oData_vw_sf_Units__x> request = ExternalQueryHandler.runQuery(fields,'DW_oData_vw_sf_Units__x',whereClause,ordering,lim);
newAR.add(NEW Async_Request__c(Request_Type__c='RQIUnitLookup',Params__c = rqi.id));
insert newAR;
test.stopTest();
}
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Remarketing Quote” process failed. Give your Salesforce admin these details. <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.: []
The error is in the line where the record of the object - Remarketing_Quote_Item__c is being created. There is a process builder that gets initiated on this object's insert. And in step 4 of this process builder a flow gets initiated, where the remarketing Quote is mapped to opportunity object and an opportunity line item gets created.
When I searched the logs, I see that the flow error is due to the error -
This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id, others must specify product id).
So, according to this error, pricebookEntry records have been created in the flow, but I still receive this error. And If I add the pricebookEntry records in the class, I receive a different error. Please help to figure out the exact issue.
Thanks,
Anketha
When I run the below test class, I receive flow related error:
Method in the class:
static testMethod void rqiTest(){
DW_oData_vw_sf_Units__x mockedRequest = new DW_oData_vw_sf_Units__x(fuel__c=true,VIN__c='ABC123');
ExternalQueryHandler.mockedObject.add(mockedRequest);
Date d=date.today()+2;
RecordType RemarketingRTid = [Select id from RecordType where SobjectType='Account' and Name='Remarketing Venue'];
RecordType OppRTid = [Select id from RecordType where SobjectType='Opportunity' and name='FMS - Standard'];
Account a= NEW Account(Name='Test', Phone='12345678',RecordTypeId=RemarketingRTid.id);
insert a;
Contact c = NEW Contact(FirstName='test',LastName='Last',AccountId=a.id);
insert c;
Opportunity o= NEW Opportunity(Name='Test',AccountId=a.id,Type='Renewal',CloseDate=d,StageName='Proposal Presented',RecordTypeId=OppRTid.id);
insert o;
Remarketing_Quote__c rq = NEW Remarketing_Quote__c(Name='Test rq',Sales_Contact__c=c.id,Status__c='Opened',Account__c=a.id,Opportunity__c=o.id);
insert rq;
Remarketing_Quote_Item__c rqi = NEW Remarketing_Quote_Item__c(Remarketing_Quote__c=rq.id,fuel__c=false,VIN__c='ABC123',Status__c='Opened',Remarketing_Venue__c=a.id);
insert rqi;
LIST<Async_Request__c> newAR = NEW LIST<Async_Request__c>();
LIST<String> fields = NEW LIST<String>{'ID','VIN__c','OWNER__c','Lease__c','Fuel__c','Telematics__c','Maintenance__c'};
String whereClause = 'WHERE VIN__c = \'ABC123\'';
String ordering;
integer lim;
Test.startTest();
LIST<DW_oData_vw_sf_Units__x> request = ExternalQueryHandler.runQuery(fields,'DW_oData_vw_sf_Units__x',whereClause,ordering,lim);
newAR.add(NEW Async_Request__c(Request_Type__c='RQIUnitLookup',Params__c = rqi.id));
insert newAR;
test.stopTest();
}
Error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, We can't save this record because the “Remarketing Quote” process failed. Give your Salesforce admin these details. <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.: []
The error is in the line where the record of the object - Remarketing_Quote_Item__c is being created. There is a process builder that gets initiated on this object's insert. And in step 4 of this process builder a flow gets initiated, where the remarketing Quote is mapped to opportunity object and an opportunity line item gets created.
When I searched the logs, I see that the flow error is due to the error -
This error occurred when the flow tried to create records: FIELD_INTEGRITY_EXCEPTION: field integrity exception: PricebookEntryId, unknown (versions 3.0 and higher must specify pricebook entry id, others must specify product id).
So, according to this error, pricebookEntry records have been created in the flow, but I still receive this error. And If I add the pricebookEntry records in the class, I receive a different error. Please help to figure out the exact issue.
Thanks,
Anketha