You need to sign in to do that
Don't have an account?
James Roberts 32
Method does not exist or incorrect signature: void put(String, Id) from the type Map<Id,Task>
I received this error when trying to create a Test Class for testing my Apex Controller that is part of a Lightning component described here:
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm
Here is my Test Class:
@isTest
public class Test_interviewsbyRecord
{
public TestMethod static void TestTask()
{
Task t = new Task();
t.subject = 'ApexTest';
t.ActivityDate= date.today();
t.Status = 'Open';
t.OwnerId = '00561000001r8ztAAA';
insert t;
List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
Map <id, Task> inputs = new Map<id, Task>();
inputs.put('TaskID',t.Id);
Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
myFlow.start();
}
}
The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause_cmp_record.htm
Here is my Test Class:
@isTest
public class Test_interviewsbyRecord
{
public TestMethod static void TestTask()
{
Task t = new Task();
t.subject = 'ApexTest';
t.ActivityDate= date.today();
t.Status = 'Open';
t.OwnerId = '00561000001r8ztAAA';
insert t;
List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
Map <id, Task> inputs = new Map<id, Task>();
inputs.put('TaskID',t.Id);
Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
myFlow.start();
}
}
The test class is created a new task and then initiating the Flow (Activity_Escalation_Flow) that is running on my Tasks. The only Variable needed for the Flow is that Task ID, which is contained in the Variable !TaskID. I don't seem to be mapping it correctly to the Input.
Please use the below code with 100% Coverage and pass.
Before that i have paused the flow. Check the highlight content in code which i have change.
below url might be helpful for you.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause.htm
Let me know if you get any other issues in that.
Best,
Yogesh
All Answers
Use like below..
Map <id, Task> inputs = new Map<id, Task>();
inputs.put(t.id,t);
Or
Map <String, Task> inputs = new Map<String, Task>();
inputs.put('TaskID',t);
In your code you are assigning 'TaskID' string which should be id according to your map.
Let me know if you get the any issue still.
Thanks,
Yogesh
public class interviewsByRecordController {
@AuraEnabled
public static List<FlowRecordRelation> getInterviews(Id recordId) {
return [ SELECT
ParentId, Parent.InterviewLabel, Parent.PauseLabel,
Parent.CurrentElement, Parent.CreatedDate, Parent.Owner.Name
FROM FlowRecordRelation
WHERE RelatedRecordId = :recordId ];
}
@AuraEnabled
public static FlowInterview deleteInterview(Id interviewId) {
FlowInterview interview = [Select Id from FlowInterview Where Id = :interviewId];
delete interview;
return interview;
}
}
Hi James,
Write these in your test class.
interviewsByRecordController.getInterviews(t.id);
interviewsByRecordController.deleteInterview('pass your interview id here');
Let me know if you get any problem.
Best,
Yogesh
System.FlowException: This error occurred when the flow tried to look up records:
Subject, Id FROM Task WHERE ((Id = '{Subject=ApexTest, ActivityDate=2019-02-13
^
ERROR at Row:1:Column:213
invalid ID field: {Subject=ApexTest, ActivityDate=2019-02-13 00:00:00, Status=Open, OwnerId=00561000001r8ztAAA, Id=00Tq000000VNJIQEA5}. You can look up ExceptionCode values in the <a href='https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#'>SOAP API Developer Guide .
Here is the test class in full.
@isTest
public class Test_interviewsbyRecord
{
public TestMethod static void TestTask()
{
Task t = new Task();
t.subject = 'ApexTest';
t.ActivityDate= date.today();
t.Status = 'Open';
t.OwnerId = '00561000001r8ztAAA';
insert t;
List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
Map <String, Task> inputs = new Map<String, Task>();
inputs.put('TaskID',t);
Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
myFlow.start();
interviewsByRecordController.getInterviews(t.id);
interviewsByRecordController.deleteInterview('myFlow');
}
}
I tried below code it it was giving 71% coverage with pass
in your above code you have passed the string myFlow in method interviewsByRecordController.deleteInterview('myFlow');
instead of myFlow you have to pass the paused flow id.
let me know if you get any other problem.
Best,
Yogesh
Please use the below code with 100% Coverage and pass.
Before that i have paused the flow. Check the highlight content in code which i have change.
below url might be helpful for you.
https://developer.salesforce.com/docs/atlas.en-us.salesforce_vpm_guide.meta/salesforce_vpm_guide/vpm_admin_pause.htm
Let me know if you get any other issues in that.
Best,
Yogesh
System.FlowException: This error occurred when the flow tried to look up records:
Subject, Id FROM Task WHERE ((Id = '{Subject=ApexTest, ActivityDate=2019-02-14
^
ERROR at Row:1:Column:213
invalid ID field: {Subject=ApexTest, ActivityDate=2019-02-14 00:00:00, Status=Open, OwnerId=00561000003NlHwAAK, Id=00Tq000000VOILgEAP}. You can look up ExceptionCode values in the <a href='https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#'>SOAP API Developer Guide .
Here is the test class now:
@isTest(SeeAllData=true)
public class Test_interviewsbyRecord
{
public TestMethod static void TestTask()
{
Task t = new Task();
t.subject = 'ApexTest';
t.ActivityDate= date.today();
t.Status = 'Open';
t.OwnerId = UserInfo.getUserId();
insert t;
List <Task> ls = [Select Id from Task where Subject = 'ApexTest'];
Map <String, Task> inputs = new Map<String, Task>();
inputs.put('TaskID',t);
Flow.Interview.Activity_Escalation_Flow myFlow = new Flow.Interview.Activity_Escalation_Flow(inputs);
myFlow.start();
FlowInterview interview = [Select Id from FlowInterview limit 1];
interviewsByRecordController.getInterviews(t.id);
interviewsByRecordController.deleteInterview(interview.id);
}
}
Thanks James
Seems your inputs(Map) have some problem.
Change it's type..
Map <String, Task> inputs = new Map<String, Task>();
inputs.put('TaskID',t);
to
Map <id, Task> inputs = new Map<id, Task>();
inputs.put(t.id,t);
Let me know if you get any error..
Thanks
Yogesh
I then have this error when saving the class:
Constructor not defined: [Flow.Interview.Activity_Escalation_Flow].<Constructor>(Map<Id,Task>) Line 18.
Thanks,
James
Please share the screen of your flow. What are the variables are there?
Anyway try once below line also.
Map <String, Id> inputs = new Map<String, Id>();
inputs.put('TaskID',t.id);
Thanks,
Yogesh
Thanks so much for your help!
Please,Mark the thread solved.
Thanks,
Yogesh