You need to sign in to do that
Don't have an account?
SIVA KUMAR 507
Hey All i need Apex test class for the below code please help me!!
Class:
---------
public class AskEDD_casecommentcreation {
@InvocableMethod
public static void ProcessBuilder_Call(list<Id> TaskId)
{
List<id> taskIds = new list<id>();
list<CaseComment> CCList = new list<CaseComment>();
list<Task> td = new list<Task>();
list<caseFeed> fi = new list<caseFeed>();
list<TaskFeed> ti = new list<TaskFeed>();
list<id> caseIds = new list<id>();
for(Id a : TaskId)
{
taskIds.add(a);
}
system.debug('Task Id is ****' +taskIds);
list<Task> tasklist = [select id, Description, WhatId from Task where id in: TaskId];
for (Task taskRecord : tasklist){
caseIds.add(taskRecord.WhatId);
system.debug('Case Id is ****' +taskRecord.WhatId);
}
fi = [select id, parentId, Type from caseFeed where parentId IN: caseIds and Type = 'CaseCommentPost'];
ti = [select id, parentId, Type from TaskFeed];
system.debug('fi = '+fi);
system.debug('ti = '+ti);
for(task t : tasklist){
system.debug('Task t Id is **** '+t);
CaseComment cc = new CaseComment();
cc.CommentBody = t.Description;
cc.ParentId = t.WhatId;
CCList.add(cc);
Task Deletet = new Task();
Deletet.id = t.id;
td.add(Deletet);
}
insert CCList;
system.debug('CCList is ****'+ CCList);
// delete ti;
// delete fi;
// system.debug('Delete feedItem list is ******'+fi);
// delete tasklist;
system.debug('Delete list is ******'+tasklist);
}
}
---------
public class AskEDD_casecommentcreation {
@InvocableMethod
public static void ProcessBuilder_Call(list<Id> TaskId)
{
List<id> taskIds = new list<id>();
list<CaseComment> CCList = new list<CaseComment>();
list<Task> td = new list<Task>();
list<caseFeed> fi = new list<caseFeed>();
list<TaskFeed> ti = new list<TaskFeed>();
list<id> caseIds = new list<id>();
for(Id a : TaskId)
{
taskIds.add(a);
}
system.debug('Task Id is ****' +taskIds);
list<Task> tasklist = [select id, Description, WhatId from Task where id in: TaskId];
for (Task taskRecord : tasklist){
caseIds.add(taskRecord.WhatId);
system.debug('Case Id is ****' +taskRecord.WhatId);
}
fi = [select id, parentId, Type from caseFeed where parentId IN: caseIds and Type = 'CaseCommentPost'];
ti = [select id, parentId, Type from TaskFeed];
system.debug('fi = '+fi);
system.debug('ti = '+ti);
for(task t : tasklist){
system.debug('Task t Id is **** '+t);
CaseComment cc = new CaseComment();
cc.CommentBody = t.Description;
cc.ParentId = t.WhatId;
CCList.add(cc);
Task Deletet = new Task();
Deletet.id = t.id;
td.add(Deletet);
}
insert CCList;
system.debug('CCList is ****'+ CCList);
// delete ti;
// delete fi;
// system.debug('Delete feedItem list is ******'+fi);
// delete tasklist;
system.debug('Delete list is ******'+tasklist);
}
}
You can try below sample code after checking your implementation.
#SampleCode
Hope above answer was helpful, Please mark as best answer so that it can help others in future.
Thanks!
All Answers
You can try below sample code after checking your implementation.
#SampleCode
Hope above answer was helpful, Please mark as best answer so that it can help others in future.
Thanks!
Thank you for Reply. And this Test Class Is Matched With My Requirement.
And I Have some Another Class can you please Help on that....?