You need to sign in to do that
Don't have an account?
sree prasad
Hi Please reply fast
How To write test class to this class
@RestResource(urlMapping='/LeadMapping/*')
global with sharing class Rest_Lead_Insert {
@HttpPost
global static String CreateNewLead(String lastname, String status,String Call_duration, string Service_Number, string AgentPhone, string Ofc_Call_Status,string Ofc_Call_Time,string office_lead_id,string AgentName,string Recording_File_Path,Boolean Office24by7,string call_type){
System.debug('lead Name: '+lastname);
System.debug('lead Status: '+status);
try
{
lead le = new lead();
le.lastname = lastname;
le.Office_Number__c = Service_Number;
le.Phone = AgentPhone;
le.Ofc_Call_duration__c = Call_duration;
le.Ofc_Call_Type__c = call_type;
le.Ofc_Call_Status__c = Ofc_Call_Status;
le.Ofc_Call_Time__c = Ofc_Call_Time;
le.office_lead_id__c = office_lead_id;
le.AgentName__c = AgentName;
le.Recording_File_Path__c = Recording_File_Path;
le.Office24by7__c = Office24by7;
le.status = status;
insert le;
return 'lead has been inserted succesfully: '+le.Id;
}
catch(DMLException de)
{
return de.getDmlMessage(0);
}
// return null;
}
}
@RestResource(urlMapping='/LeadMapping/*')
global with sharing class Rest_Lead_Insert {
@HttpPost
global static String CreateNewLead(String lastname, String status,String Call_duration, string Service_Number, string AgentPhone, string Ofc_Call_Status,string Ofc_Call_Time,string office_lead_id,string AgentName,string Recording_File_Path,Boolean Office24by7,string call_type){
System.debug('lead Name: '+lastname);
System.debug('lead Status: '+status);
try
{
lead le = new lead();
le.lastname = lastname;
le.Office_Number__c = Service_Number;
le.Phone = AgentPhone;
le.Ofc_Call_duration__c = Call_duration;
le.Ofc_Call_Type__c = call_type;
le.Ofc_Call_Status__c = Ofc_Call_Status;
le.Ofc_Call_Time__c = Ofc_Call_Time;
le.office_lead_id__c = office_lead_id;
le.AgentName__c = AgentName;
le.Recording_File_Path__c = Recording_File_Path;
le.Office24by7__c = Office24by7;
le.status = status;
insert le;
return 'lead has been inserted succesfully: '+le.Id;
}
catch(DMLException de)
{
return de.getDmlMessage(0);
}
// return null;
}
}
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement. As I don't have custom fields in lead object, so I have tested with standard fields.
Class:
Test Class:
According to your class, you can use below test class:
Note: Please enter the fields name according to your org and type of field in CreateNewLead parameters. Also, please add other required fields if needed.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
am getting this error Method does not exist or incorrect signature: void CreateNewLead() from the type Rest_Lead_Insert