trigger AccounttTrigger on Account(after insert){
HelperclassQ1.disp(trigger.new);
}
//////////////
public class HelperclassQ1 {
public static void disp(list<account> aclist)
{
list<contact> con = new list<contact>();
for(account conob: aclist)
{
for(integer j=0;j<conob.NumberOfEmployees;j++)
{
contact co= new contact();
co.lastname='kumar';
co.AccountId = conob.id;
con.add(co);
}
}
insert con;
}
//////////////////////////////////////////////////////
@istest
public class HelperclassQ1Test {
@istest
public static void testAcocunt()
{
account ac = new account();
ac.name= 'Test';
ac.NumberOfEmployees = 5;
insert ac;
}
}
This code will work whenever you insert an account and when you run the test class you don't need o call the main class as it will automatically run after inserting an account because we have written a trigger on the insert account.
trigger AssignedResourceTrigger on AssignedResource (after delete) {
if(trigger.isafter && trigger.isdelete) {
map<string,object> params = new map<string,object>();
params.put('AssignedResources', trigger.new);
flow.Interview.Add_Assigned_UserIds_to_the_Service_Appointment_Delete_Trigger myFlow = new flow.Interview.Add_Assigned_UserIds_to_the_Service_Appointment_Delete_Trigger(params);
myFlow.start();
}
}
Test Class: I don't think this right
@isTest
private class AssignedResourceTestClass {
@isTest static void validateAssignedResource() {
// data creation
Id serviceAgentRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Service Agent').getRecordTypeId();
Account newPersonAccount = new Account();
newPersonAccount.put('FirstName', 'Test');
newPersonAccount.put('LastName', 'Agent');
newPersonAccount.RecordTypeId = serviceAgentRecordTypeId;
insert newPersonAccount;
ServiceAppointment sa = new ServiceAppointment(
ParentRecordId = newPersonAccount.id
);
insert sa;
//retrieve service appointment
Test.startTest();
Test.stopTest();
// assert statements
}
}
I am trying to assign a resource to a service appointment, then delete the assigned resource without deleting the other resources from the service appointment. Kind of lost from here. Not sure what to put. Hope that makes sense.
Oh, I'm writing it now and also facing some problems. I have a lot of courses this year, and I can't be focused only on that and have to do other tasks. And I have to write a lot of papers, and as you know, it takes a lot of time and effort. But last time I used this service https://papersowl.com/write-my-assignment when I faced some problems and needed someone to help to write my assignment, and saved a lot of time. And finished results were amazing, and I also managed to finish other tasks faster. So I think I'll use such help more often and will practice more in writing codes.
This code will work whenever you insert an account and when you run the test class you don't need o call the main class as it will automatically run after inserting an account because we have written a trigger on the insert account.
Please mark it as Best Answer if it helps you.
Thanks & Regards
Suraj Tripathi
Try Below Refference Please Mark It As Best Answer If It Helps
Thanks You!
Hi,
Test Class: I don't think this rightThank you both for replying.
Currently this is my Trigger:
I am trying to assign a resource to a service appointment, then delete the assigned resource without deleting the other resources from the service appointment. Kind of lost from here. Not sure what to put. Hope that makes sense.