You need to sign in to do that
Don't have an account?
Kasia Wojewodzka 7
Assigning Task to a Task Queue in Test Class
Dear Community,
I wonder if someone can assit me with the Test Class I am wrrting for a Process Builder.
User creates a Task from a Case
Status od The Task Open
Field Queue (picklist) s populated) with Backoffice UK Ref Lab Support
Record Type of Task is CAG EMEA Lab Services Escalation Task.
We would like to test if this Task is indeed assigne fto the Task Queue ( Backoffice UK Ref Lab Support)
I am getting error Error: Compile Error: A non foreign key field cannot be referenced in a path expression: OwnerId at line 36 column 43
How would I fix the error?
Any help is much appriciated.
Thank you
Kasia
I wonder if someone can assit me with the Test Class I am wrrting for a Process Builder.
User creates a Task from a Case
Status od The Task Open
Field Queue (picklist) s populated) with Backoffice UK Ref Lab Support
Record Type of Task is CAG EMEA Lab Services Escalation Task.
We would like to test if this Task is indeed assigne fto the Task Queue ( Backoffice UK Ref Lab Support)
I am getting error Error: Compile Error: A non foreign key field cannot be referenced in a path expression: OwnerId at line 36 column 43
How would I fix the error?
Any help is much appriciated.
Thank you
Kasia
@isTest public class Test_PB_Task_CAGEMAQueueRouting { @testSetup static void TaskCreateData(){ //Case creation Case c = new Case(Subject='Test Case'); c.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('CAG Lab Services Case').getRecordTypeId(); insert c; } @isTest static void ValidTaskTest(){ Id taskOwnerId = [SELECT Id FROM User WHERE Name = 'test user'].Id; //Task Creation Task taskObj = new Task(); taskObj.Subject = 'Test'; taskObj.Queue__c = 'Backoffice UK Ref Lab Support'; taskObj.OwnerId = TaskOwnerId; taskObj.Status = 'Open'; taskObj.RecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('CAG EMEA Lab Services Escalation Task').getRecordTypeId(); Test.startTest(); insert taskObj; Test.stopTest(); //fetching task details Task taskUpdateObj = [SELECT Id,OwnerId FROM Task LIMIT 1]; system.assertEquals(taskUpdateObj.OwnerId.Name,'Backoffice UK Ref Lab Support'); } }
system.assertEquals(taskUpdateObj.Queue__c,'Backoffice UK Ref Lab Support');
system.assertEquals(taskUpdateObj.Owner.Name,'test usert');