• Sai Theja
  • NEWBIE
  • 90 Points
  • Member since 2017
  • Senior Software Engineer
  • Navtech

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 13
    Questions
  • 9
    Replies
Hi All,

I have picklist component with 5 (A,B,C,D,E) values. and my requirement is when user select A or B then it will redirect to  the new VF page else it will remain on same page for other Values selection.

Thanks,
Anish
Json Body:

"clients_services": [
            {
                "name": "FEZ",
                "active": true,
                "billing_rate": "11.0",
                "billing_rate_type": "of_fee"
            },
            {
                "name": "State",
                "active": true,
                "billing_rate": "11.0",
                "billing_rate_type": "of_fee"
            },
            {
                "name": "WOTC",
                "active": false,
                "billing_rate": "11.0"
            }
        ]

apex class:

List<Map<String, Object>> myMaps = new List<Map<String, Object>>();  
    List<Object> cs_results = (List<Object>) sf_result.get('clients_services');     
    list<Clients_Services__c> cs = [select Active__c, Active_Checkbox__c, service__c, Billing_Rate__c, Billing_Rate_Type__c,opportunity__c FROM Clients_Services__c where Opportunity__r.AccountId = :id];
    for (Object res : cs_results) {     
    }      


Here i need to check if record exits update else insert. 
I'm integrating Salesforce to other application(Ruby). I'm able to sync data both ways. But while updating data from Application to salesforce, every time i have to provide access token. So is there any way to get a permanent Access token?
Thank You..
Hello,
Below is my Class:
 
Global Class AgileClient{ 
public AgileClient(ApexPages.StandardController controller) {
}
webservice static void SyncClient()
{   
String currentRecordId;
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
Account a = [SELECT Id,Name,BillingAddress,BillingCity,BillingCountry,BillingState,BillingStreet,BillingPostalCode,Client_City__c,Payroll_Contact__c,client_Id__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,Primary_Contact_Text__c,Primary_Contact__r.Phone,Primary_Contact__r.Email,Payroll_Contact_Text__c,Phone__c,Client_State__c , Contact_Name__c, Phone,(select Name, Email from contacts),(select Name from location__r)  from Account where id =: currentRecordId] ;  
//if(a.client_Id__c != null){
//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Already Synced with Agile'));
//}
//else{
JSONGenerator gen = JSON.createGenerator(true);    
gen.writeStartObject(); 
createJsonRequest.writeStringField(gen, 'name', a.name);
createJsonRequest.writeStringField(gen, 'city',a.BillingCity);
createJsonRequest.writeStringField(gen, 'address_line_1',a.BillingStreet);
createJsonRequest.writeStringField(gen, 'state_code',a.BillingState);
createJsonRequest.writeStringField(gen, 'zip_code',a.BillingPostalCode);
createJsonRequest.writeStringField(gen, 'sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();        
createJsonRequest.writeStringField(gen, 'name',  a.Primary_Contact_Text__c);
createJsonRequest.writeStringField(gen, 'email', a.Primary_Contact__r.Email);
createJsonRequest.writeStringField(gen, 'phone', a.Primary_Contact__r.Phone);
gen.writeEndObject();    
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();        
createJsonRequest.writeStringField(gen, 'name', a.Payroll_Contact_Text__c);
createJsonRequest.writeStringField(gen, 'phone', a.Phone__c);  
gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('Client Data'+jsonS);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','1e3ed72468207930357c85c4717580d727f944936156ab40274049db7c6b77a84ce087f1de161725b196927d38be95b03a299f470a0f6c4c6ce19a254a0d42f4');
request.setHeader('X-API-KEY', 'yqvNrVR5Cs6vhLq1ZRPq38GM5OrXJ7C97n4BZCJa');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
try {
    Account result = (Account)JSON.deserialize(response.getBody(), Account.class);
    a.client_Id__c = String.valueOf(result.id);
Update a;
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Client Created Successfully'));

} catch(DmlException e) {
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
}

//System.debug('Account:'+result.id);
// System.debug('Client Created Successfully: ' +
//   response.getStatusCode() + ' ' + response.getBody());
} else {
    System.debug('Unable to create Client: ' +
        response.getStatusCode() + ' ' + response.getBody());
     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, response.getBody()));
}
//}
}
}

 
I covered 40% with the below test class. Help me to cover 75%.
Apex Class:
public class FFQExt 
{
Public attachment objAttachment
{
get
{
if (objAttachment == null)
objAttachment = new Attachment();
return objAttachment ;
}
set;
}
public Id recordId {get; set;}
Public FFQ__C l{get; set;}
public String currentRecordId {get;set;}
public FFQExt(ApexPages.StandardController stdCon) 
{
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
this.recordId = stdCon.getId();
this.l = (FFQ__c)stdCon.getRecord();  
objAttachment = new Attachment();
l = new FFQ__c();
l = [select Name, id, Business_Address__c, Business_Phone_Number__c, City__c, Client__c, Corporate_Structure__c, County__c, CPA_Contact__c, CPA_Contact_Email__c, 
CPA_Contact_Name__c, CPA_Contact_Phone__c, Do_you_ever_rehire_employees__c, MultipleEIN__c, Do_you_have_plans_for_Future_Expansion__c, Do_you_have_Recent_Expansion__c,
EIN__c, Estimated_Date_of_Tax_Filing__c, estimated_number_of_employees_hired_per__c, Executive_Contact__c, Executive_Contact_Email__c, Executive_Contact_Name__c,
Executive_Contact_Phone__c, Federal_Empowerment_Zone_Wage_Credit__c, First_Name__c, First_NameofPerson__c, Fiscal_Year_End_Date__c, General_Tax_Status__c, 
How_many_current_employees_do_you_have__c, How_many_W2s_were_distributed_last_year__c, HR_Contact__c, HR_Contact_Email__c, HR_Contact_Name__c, HR_Contact_Phone__c,
HR_Platform_to_onboard_your_Employees__c, Indian_Employment_Tax_Credit__c, Invoice_Contact__c, Invoice_Contact_Email__c, Invoice_Contact_Name__c, Invoice_Contact_Phone__c,
Legal__c, Is_your_business_Seasonal__c, I_understand__c, Last_Name__c, Last_NameofPerson__c, Legal_Address__c, Legal_City__c, Legal_County__c, Legal_Entity_Name__c, Legal_State__c,
Legal_Zip__c, list_all_locations_worksites__c, Payroll_Contact__c, Payroll_Contact_Email__c, Payroll_Contact_Name__c, Payroll_Contact_Phone__c, Please_list_all_EIN_Legal_Entities_below__c, 
Primary_Contact_Email__c, Primary_Contact_Number__c, Primary_Contact_Title__c, State__c, States_State_IDs_with_Tax_Liability__c, State_Specific_Incentives__c, To_begin_participation__c,
Which_HR_Platform_are_you_utilizing__c, Which_Payroll_Provider_are_you_using__c, WOTC__c, Zip__c from FFQ__c where id =: currentRecordId ];

}
Public void dosave()
{
if(objAttachment.body == null) 
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please upload your Documents'));
return ApexPages.CurrentPage();
}
else
{
upsert l;
objAttachment.ParentId = l.id;
try 
{
upsert objAttachment;
}
catch (DMLException e) 
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error Submitting Form'));
return null;
}
finally
{
objAttachment.body = null; // clears the viewstate
objAttachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Form Submitted Successfully'));
 PageReference mypage = new PageReference('/apex/thankyou');
   mypage.setRedirect(true);
   return mypage;
return null;
}
}
}
Test Class:
 
@isTest
private class FFQExt_Test1{
  @testSetup
  static void setupTestData(){
    test.startTest();
    FFQ__c ffq_Obj = new FFQ__c(Name = 'Name714', First_Name__c = 'First917', Last_Name__c = 'Last_775', Primary_Contact_Title__c = 'Prima305', Primary_Contact_Email__c = 'Email16@test.com', Primary_Contact_Number__c = '54343-6724', Business_Address__c = '18', City__c = 'City__c632', State__c = 'Alabama', Zip__c = 'Zip__c497', Business_Phone_Number__c = '54343-92658', Legal_Entity_Name__c = 'Legal220', Legal__c = false, EIN__c = 25, MultipleEIN__c = false, Please_list_all_EIN_Legal_Entities_below__c = '27', list_all_locations_worksites__c = '28', Corporate_Structure__c = 'C-Corp', Estimated_Date_of_Tax_Filing__c = Date.today(), General_Tax_Status__c = 'Paying Regular Tax', Fiscal_Year_End_Date__c = Date.today(), States_State_IDs_with_Tax_Liability__c = '33', Do_you_have_Recent_Expansion__c = false, Do_you_have_plans_for_Future_Expansion__c = false, Executive_Contact_Name__c = 'Execu607', Executive_Contact_Email__c = 'Email37@test.com', Executive_Contact_Phone__c = '54343-11689', CPA_Contact_Name__c = 'CPA_C106', CPA_Contact_Phone__c = '54343-93693', CPA_Contact_Email__c = 'Email41@test.com', HR_Contact_Name__c = 'HR_Co140', HR_Contact_Email__c = 'Email43@test.com', HR_Contact_Phone__c = '54343-70632', Invoice_Contact_Name__c = 'Invoi739', Invoice_Contact_Email__c = 'Email46@test.com', Invoice_Contact_Phone__c = '54343-50578', Payroll_Contact_Name__c = 'Payro557', Payroll_Contact_Email__c = 'Email49@test.com', Payroll_Contact_Phone__c = '54343-67706', HR_Platform_to_onboard_your_Employees__c = 'Yes', Which_HR_Platform_are_you_utilizing__c = 'Which567', Which_Payroll_Provider_are_you_using__c = 'Which997', How_many_current_employees_do_you_have__c = 54, How_many_W2s_were_distributed_last_year__c = 55, estimated_number_of_employees_hired_per__c = 'estim415', Is_your_business_Seasonal__c = 'Is_yo660', Do_you_ever_rehire_employees__c = 'Do_yo497', First_NameofPerson__c = 'First430', Last_NameofPerson__c = 'Last_585', Legal_Address__c = '61', Legal_City__c = 'Legal521', Legal_Zip__c = 63, Legal_State__c = 'Alabama', WOTC__c = false, State_Specific_Incentives__c = false, Federal_Empowerment_Zone_Wage_Credit__c = false, Indian_Employment_Tax_Credit__c = false, Executive_Contact__c = false, CPA_Contact__c = false, HR_Contact__c = false, Invoice_Contact__c = false, Payroll_Contact__c = false, To_begin_participation__c = '74', County__c = 'Count208', Legal_County__c = 'Legal590', I_understand__c = 'Yes');
    Insert ffq_Obj; 
    test.stopTest();
  }
  static testMethod void test_dosave_UseCase1(){
    List<FFQ__c> ffq_Obj  =  [SELECT Id,Name,First_Name__c,Last_Name__c,Primary_Contact_Title__c,Primary_Contact_Email__c,Primary_Contact_Number__c,Business_Address__c,City__c,State__c,Zip__c,Business_Phone_Number__c,Legal_Entity_Name__c,Legal__c,EIN__c,MultipleEIN__c,Please_list_all_EIN_Legal_Entities_below__c,list_all_locations_worksites__c,Corporate_Structure__c,Estimated_Date_of_Tax_Filing__c,General_Tax_Status__c,Fiscal_Year_End_Date__c,States_State_IDs_with_Tax_Liability__c,Do_you_have_Recent_Expansion__c,Do_you_have_plans_for_Future_Expansion__c,Executive_Contact_Name__c,Executive_Contact_Email__c,Executive_Contact_Phone__c,CPA_Contact_Name__c,CPA_Contact_Phone__c,CPA_Contact_Email__c,HR_Contact_Name__c,HR_Contact_Email__c,HR_Contact_Phone__c,Invoice_Contact_Name__c,Invoice_Contact_Email__c,Invoice_Contact_Phone__c,Payroll_Contact_Name__c,Payroll_Contact_Email__c,Payroll_Contact_Phone__c,HR_Platform_to_onboard_your_Employees__c,Which_HR_Platform_are_you_utilizing__c,Which_Payroll_Provider_are_you_using__c,How_many_current_employees_do_you_have__c,How_many_W2s_were_distributed_last_year__c,estimated_number_of_employees_hired_per__c,Is_your_business_Seasonal__c,Do_you_ever_rehire_employees__c,First_NameofPerson__c,Last_NameofPerson__c,Legal_Address__c,Legal_City__c,Legal_Zip__c,Legal_State__c,WOTC__c,State_Specific_Incentives__c,Federal_Empowerment_Zone_Wage_Credit__c,Indian_Employment_Tax_Credit__c,Executive_Contact__c,CPA_Contact__c,HR_Contact__c,Invoice_Contact__c,Payroll_Contact__c,To_begin_participation__c,County__c,Legal_County__c,I_understand__c from FFQ__c];
    System.assertEquals(true,ffq_Obj.size()>0);
    PageReference pageRef = Page.FFQ;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);
    FFQExt obj01 = new FFQExt(new ApexPages.StandardController(ffq_Obj[0]));
    obj01.objAttachment = new attachment();
    obj01.recordId = '01p90000006uk2w';
    obj01.l = ffq_Obj[0];
    obj01.currentRecordId = 'test data';
    obj01.dosave();
  }
}


 
Hello, i want test class for the below Apex Webservice Class:


Global Class AgileClient{ 
public AgileClient(ApexPages.StandardController controller) {
}
webservice static void SyncClient()
{   
String currentRecordId;
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
Account a = [SELECT Id,Name,Client_City__c,Payroll_Contact__c,client_Id__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,Primary_Contact_Text__c,Primary_Contact__r.Phone,Primary_Contact__r.Email,Payroll_Contact_Text__c,Phone__c,Client_State__c , Contact_Name__c, Phone,(select Name, Email from contacts),(select Name from location__r)  from Account where id =: currentRecordId] ;  
//if(a.client_Id__c != null){
//ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Already Synced with Agile'));
//}
//else{
JSONGenerator gen = JSON.createGenerator(true);    
gen.writeStartObject(); 
createJsonRequest.writeStringField(gen, 'name', a.name);
createJsonRequest.writeStringField(gen, 'city',a.Client_City__c);
createJsonRequest.writeStringField(gen, 'address_line_1',a.Client_Address__C);
createJsonRequest.writeStringField(gen, 'state_code',a.Client_State__c);
createJsonRequest.writeStringField(gen, 'zip_code',a.Client_Zip__c );
createJsonRequest.writeStringField(gen, 'sf_id',a.Id);
gen.writeFieldName('primary_contact_attributes');
gen.writeStartObject();        
createJsonRequest.writeStringField(gen, 'name',  a.Primary_Contact_Text__c);
createJsonRequest.writeStringField(gen, 'email', a.Primary_Contact__r.Email);
createJsonRequest.writeStringField(gen, 'phone', a.Primary_Contact__r.Phone);
gen.writeEndObject();    
gen.writeFieldName('payroll_contact_attributes');
gen.writeStartObject();        
createJsonRequest.writeStringField(gen, 'name', a.Payroll_Contact_Text__c);
createJsonRequest.writeStringField(gen, 'phone', a.Phone__c);  
gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('Client Data'+jsonS);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
try {
    Account result = (Account)JSON.deserialize(response.getBody(), Account.class);
    a.client_Id__c = String.valueOf(result.id);
Update a;
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Client Created Successfully'));

} catch(DmlException e) {
    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
}

//System.debug('Account:'+result.id);
// System.debug('Client Created Successfully: ' +
//   response.getStatusCode() + ' ' + response.getBody());
} else {
    System.debug('Unable to create Client: ' +
        response.getStatusCode() + ' ' + response.getBody());
     ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, response.getBody()));
}
//}
}
}
Below is my code:

Location__c loc = [SELECT Id,Name,Company__r.company_id__c,Location_Address__c,Location_City__c,Location_Zip__c,Location_State__c,Location_Participation_Method__c from Location__c where id = 'a0P2C000001KkEa'] ;  
JSONGenerator gen = JSON.createGenerator(true);  
    Decimal companyID = loc.Company__r.Company_id__c;


    gen.writeStartObject();      
    gen.writeStringField('location_name',loc.name);
    system.debug(loc.Company__r.company_id__c);
    system.debug('https://api-qa.retrotax-aci.com/companies/'+CompanyID+'/locations');
    // gen.writeStringField('Company_id',String.valueOf(loc.Company__r.company_id__c));
    gen.writeStringField('address_line_1',loc.Location_Address__c);
    gen.writeStringField('sf_id',loc.id);
    gen.writeStringField('city',loc.Location_City__c );
    gen.writeStringField('zip_code',loc.Location_Zip__c );
    gen.writeStringField('state_code',loc.Location_State__c);
    gen.writeSrtingField('participation_methods', loc.Location_Participation_Method__c); 
gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('Location Data'+jsonS);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/companies/'+CompanyID+'/locations');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxx);
request.setHeader('X-API-KEY', 'xxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
Location__c result = (Location__c) JSON.deserialize(response.getBody(), Location__c.class);
System.debug('Location:'+result.id);
loc.Location_Id__c = Decimal.valueOf(result.id);
update loc;

    System.debug('Location Created Successfully: ' +
        response.getStatusCode() + ' ' + response.getBody());
} else {
    System.debug('Unable to create Location: ' +
        response.getStatusCode() + ' ' + response.getBody());
     
}

Here "Loaction_Participation_method__c"  is MutliSelect Picklist.
i need to get these values in array format i.e. (["Combo","Paper"]).
below is my result:
User-added image
Hello,
I have post method to store salesforce data to external system. In response i'm getting Id from that system. how to save that id in salesforce Account field (Client_id__c).
below is my code:

Account a = [SELECT Id,Name, Client_City__c,Payroll_Contact__c, Client_Address__C,Client_Zip__c ,Primary_Contact__c,State_Code__c,Phone__c,State__c, Contact_Name__c, Phone,(select Name from contacts),(select Name from location__r)  from Account where id = '0012C00000LcvQn'] ;  
JSONGenerator gen = JSON.createGenerator(true);    
    gen.writeStartObject();      
    gen.writeStringField('name',a.name);
    gen.writeStringField('address_line_1',a.Client_Address__c);
    gen.writeStringField('city',a.Client_City__c);
    gen.writeStringField('state_code',a.State_Code__c );
    gen.writeStringField('zip_code',a.Client_Zip__c );
    gen.writeStringField('sf_id',a.Id);
    gen.writeFieldName('primary_contact_attributes');
    gen.writeStartObject();        
    gen.writeObjectField('name', a.contacts[0].Name);
    gen.writeObjectField('phone', a.Phone__c);  
    gen.writeEndObject();    
    gen.writeFieldName('payroll_contact_attributes');
    gen.writeStartObject();        
    gen.writeObjectField('name', a.Payroll_Contact__c);
    gen.writeObjectField('phone', a.Phone__c);  
    gen.writeEndObject();    

    gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('jsonMaterials'+jsonS);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/clients');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('X-API-KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
  
    System.debug('Client Created Successfully: ' +
        response.getStatusCode() + ' ' + response.getBody());
} else {
    System.debug('Unable to create Client: ' +
        response.getStatusCode() + ' ' + response.getBody());
   }


Response Screen Shot
User-added imageHere im getting Id:655, i need to store that id in salesforce.

 
Im new to salesforce
I need Test class for following Triggers to cover my code coverage

1.
trigger AccountCheckbox on Account (before update) {
if(trigger.isUpdate){
for(Account a : trigger.new){
if(a.Record_Updated__c == false){
a.Record_Updated__c = true;
}
}
}
}
--------------------------------------------------------------------------------------------
2.

trigger ClosedOpportunityTrigger on Opportunity (after insert,after update) {
List<task> sai = New List<task>();

  for(opportunity opp:trigger.new){
   if(opp.stagename=='closed won'){
    task t=new task(whatid=opp.id);
    
    t.Subject = 'Opportunity Task';
    t.type= 'Call' ;
    t.ActivityDate = system.today();     
    
    sai.add(t); 
    }
   }
     insert sai;
}

---------------------------------------------------------------------------------------
3.


trigger DuplicateTask on Task (before insert, before update) {
for(task t : trigger.new){
list<task> tas = [select subject from task where subject = : t.subject];
if (tas.size()>0){
t.adderror('Task Name already exits');
}
}
}

 
I have two screens (Screen1, Screen2) in a Flow. If Current Time Equals to Business Hours Time It should disply Screen1 else it Should Display Screen2. But it is Displaying only either Screen1 or Screen2. Please Help... 
help me in test class to code coverage
I have a batch apex class and a test class. But im getting only 60% of code coverage please help me to get above 75%

Class:

global class FacultyearnGFCBatch implements Database.Batchable<sObject>


    
    global Database.QueryLocator start(Database.BatchableContext bc)
    { 
       integer year = system.today().year();
        string str1 = (year-1)+'-'+(year);
        string Campus1 = 'Boston';
        string Campus2 = 'BRD';
        string Campus3 = 'BOS';
        string inputCampus1 = '\''+'%'+ Campus1+'%'+'\'';
        string inputCampus2 = '\''+'%'+ Campus2+'%'+'\'' ;
        string inputCampus3 = '\''+'%'+ Campus3+'%'+'\'' ;
        String[] Str = new string[]{str1};
        string result = '\''+String.join(Str,'\',\'')+'\'';    
        string Class1 = 'No Payment for this Class';
        string Class2 = '\''+'%'+ Class1+'%'+'\'';
        
        
        
Id strFacultyTeachingAssignment = NEUSFIDHelper.retrieveRecordTypeId(APIPConstants.REC_TYPE_FACULTY_TEACHING_ASSIGNMENT, 'Contract');
string query1 = 'SELECT id,Account.Name,Cancelation_Fee_Scheduled__c,Canceled_Contract_Fee__c,Course_Section_ID__r.course_section_status__c,Compensation_Rate__r.name,Course_Section_ID__c,AccountId FROM Contract WHERE ';
query1=query1+'RecordType.Id IN('+'\''+strFacultyTeachingAssignment+'\''+')';
query1=query1+'AND Cancelation_Fee_Scheduled__c = True ';
query1=query1+'AND Course_Section_ID__r.course_section_status__c = \'Cancelled\' ';
query1=query1+'AND  Canceled_Contract_Fee__c  IN ( \'100% GFC Fee\',\'75% GFC Fee\') ';
query1=query1+'AND (NOT Compensation_Rate__r.name like '+Class2+')';


List<Contract> cancContractLst = Database.query(query1);
        
    string query2 = 'SELECT ID,Account.Name,AccountId,Course_Sections__c,Course_Section_ID__c,Account.Faculty_Employment_Status__pc,Account.CPS_faculty_type__pc,Campus__c,Academic_Year__c,Term__c,Account.Union_Member__c,Account.NU_Id__c,Status From Contract  WHERE ' ;
    query2=query2+'RecordType.Id IN('+'\''+strFacultyTeachingAssignment+'\''+')';
    query2=query2+'AND  Academic_Year__c IN ('+result+')';
    query2=query2+'AND Status = \'Activated\'';
    query2=query2+'AND Account.Union_Member__c = True ';
    query2=query2+'AND Account.Faculty_Employment_Status__pc = \'Active\'';
    query2=query2+'AND Account.CPS_faculty_type__pc NOT IN ( \'Full Time Faculty\',\'Half Time Faculty\') ';
    query2=query2+'AND (Campus__c Like '+inputCampus1+'OR Campus__c Like '+inputCampus2+'OR Campus__c Like '+inputCampus3+')';
   
     List<Contract> activeContractLst = Database.query(query2);

    List<Id> contractLst = new List<Id>();
      for(Contract c2 : activeContractLst) {
            contractLst.add(c2.Id);
        }
        for(Contract c1 : cancContractLst) {
            contractLst.add(c1.Id);
        }
        
    List<Faculty_Good_Faith_Consideration__c> facLst = [Select id,name,Contract__c,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c where Contract__c IN : contractLst];
    List<Id> idList = new List<Id>();
    List<Faculty_Good_Faith_Consideration__c> updateAboutlst = new List<Faculty_Good_Faith_Consideration__c>();

    for(Faculty_Good_Faith_Consideration__c fac : facLst) {
          if(fac.Course_Section__r.Course_Section_Status__c == 'Cancelled') {
            Faculty_Good_Faith_Consideration__c gc = new Faculty_Good_Faith_Consideration__c(id=fac.Id);
            gc.Accepted_Buyout__c = true;
            gc.GFC_For_Given_Course__c = false;
              updateAboutlst.add(gc);
          }
          idList.add(fac.Contract__c);          
    }

    if(updateAboutlst.size()>0)
      update updateAboutlst;

    Set<Id> newConSet = new Set<Id>(contractLst);
    Set<Id> exConSet = new Set<Id>(idList);
    List<Id> dupes = new List<Id>();
    for(Id ct : newConSet) {
      if(exConSet.contains(ct)) {
        dupes.add(ct);
      }
    }
    newConSet.removeAll(dupes);

    String query = 'Select id,Account.Name,AccountId,Course_Sections__c,Course_Section_Status__c,Course_Section_ID__c,Account.Faculty_Employment_Status__pc,Account.CPS_faculty_type__pc,Campus__c,Academic_Year__c,Term__c,Account.Union_Member__c,Account.NU_Id__c,Cancelation_Fee_Scheduled__c,Canceled_Contract_Fee__c,Status,Compensation_Rate__r.name from Contract where ID IN';
            query = query + ' :newConSet';
     
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext bc, List<Contract> scope)
    {                 
        list<Contract> updateContractList  = new list<Contract>();
        list<Faculty_Good_Faith_Consideration__c> gfcLst = new List<Faculty_Good_Faith_Consideration__c>();
        List<Faculty_Good_Faith_Consideration__c>  updategfcLst = new List<Faculty_Good_Faith_Consideration__c>();
        Map<id,String> gfcCancelled = new Map<id,String>();
        
        for(Contract Con : scope)
        {          

          if(con.Status == 'Activated'){

          Faculty_Good_Faith_Consideration__c facl = new Faculty_Good_Faith_Consideration__c();
             facl.Name   = con.Account.Name ;
             facl.Contract__c = con.Id;
             facl.Course_Section__c = con.Course_Section_ID__c;
             facl.AccountName__c  = con.AccountId;
             facl.GFC_For_Given_Course__c  = True;
           gfcLst.add(facl);
             
        }  
        
        if(con.Course_Section_Status__c == 'Cancelled') {            
             gfcCancelled.put(con.Id,con.Course_Section_ID__c);             
        }
      
      }           
          
            
        try {         
              if(gfcLst.size()>0)
                insert gfcLst;

              if(gfcCancelled.size()>0) {
                 List<Faculty_Good_Faith_Consideration__c> gfcCancLst = [Select id,name,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c where Course_Section__c IN :gfcCancelled.values()];
                    
                   for(Faculty_Good_Faith_Consideration__c gfcCanc: gfcCancLst) {
                   
                   Faculty_Good_Faith_Consideration__c gf = new Faculty_Good_Faith_Consideration__c(id = gfcCanc.Id);
                   gf.Accepted_Buyout__c  = True;
                   gf.GFC_For_Given_Course__c = false;
                   updategfcLst.add(gf);
                   
                   }
                }
              if(updategfcLst.size()>0) {
              database.SaveResult[] srlist = database.update(updategfcLst,false);             

              for(database.SaveResult sr : srlist)
              {
                  if(sr.isSuccess())
                  {
                      system.debug('Successfully updated GFC Records:'+sr.getId());
                  } 
                  else
                  {                         
                      for(database.Error err : sr.getErrors())
                      {
                          system.debug(err.getStatusCode()+':'+err.getMessage());
                      }
                         
                   }
                  }                                                     
               }
               
           }catch(Exception e){
                System.debug(e.getMessage());
            }   
     }       
    global void finish(Database.BatchableContext BC)
    {
       
    }
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
Test Class:


@isTest
public class FacultyearnGFCBatchTest {      

    @TestSetup
    public static void setup() {    
    
    Id CPS_ACCOUNT_REC_TYPE = NEUSFIDHelper.retrieveRecordTypeId(CPSConstants.REC_TYPE_ACCOUNT_APPLICANT, 'Account');
    Id TEACHING_ASSIGNMENT_REC_TYPE = NEUSFIDHelper.retrieveRecordTypeId(CPSConstants.FACULTY_TEACHING_ASSIGNMENT_RECORD_TYPE_NAME, 'Contract');

     Account acc = new Account(FirstName = 'Novak', LastName = 'Djokovic', CPS_faculty_type__pc = 'Lecturer' ,Faculty_Employment_Status__pc ='Active', Union_Member__c = true, NU_ID__c = '1112229', RecordTypeId = CPS_ACCOUNT_REC_TYPE);
     insert acc;
     Term__c term = 
       new Term__c(
                        Name = 'Winter 2022 CPS Quarter',
                        Term_External_Id__c = '006A',
                        Academic_Year__c = '2022');
       insert term;

       Part_of_Term__c partofTerms =
       new Part_of_Term__c(
                    Name = '8',
                        Term__c = term.Id,
                         Short_Name__c = 'Spring 2022, First Six-week Session',
                         Part_of_Term_External_Id__c = 'A10008',
                        Start_Date_Part_of_Term__c = Date.parse('4/1/2022'));
       insert partofTerms;


         Course_Catalog__c courseCatalog = 
            new Course_Catalog__c(Name = 'cat-1');

         insert courseCatalog;

          Course_Section__c cSec = new Course_Section__c(
                        Name = '202215-80001',
                        CRN__c = '80001',
                        Course_Catalog__c = courseCatalog.id,
                        Part_of_Term__c = partofTerms.Id,
                        Credit_Hours__c = 3,
                        Payroll_Actual_Enrollment__c = 0,
                        Course_Section_Status__c  = 'Active');
          insert cSec;

           Compensation_Rate__c compensationRate =
           new Compensation_Rate__c(
                        Name = 'No Payment for this Class',
                        RecordTypeId = CPSCompensationRateUtil.getRecordTypeId('Base Contract Pay'),
                        Rate_Type__c = 'Flat Amount',
                        Amount__c = 8000);
           insert compensationRate;
           Contract contract =null;
                    contract = new Contract(
                    AccountId = acc.Id,
                    Academic_Year__c = '2018-2019',
                    Is_Canceled__c = false,
                    StartDate = Date.newInstance(2018, 10, 10),
                    RecordTypeId = TEACHING_ASSIGNMENT_REC_TYPE,
                    Course_Section_ID__c = cSec.id,
                    Type__c = 'Primary',
                    Status = 'Draft',
                    Campus__c = 'Boston',
                    Canceled_Contract_Fee__c = '100% GFC Fee',
                    Compensation_Rate__c = compensationRate.id);
            insert contract;
            
            Course_Section__c cs = new Course_Section__c(Id=cSec.Id);
            cs.Course_Section_Status__c ='Cancelled';
            update cs;

            Contract con = new Contract(Id = contract.Id);
            con.Status ='Activated';
            update con;

            Faculty_Good_Faith_Consideration__c fac = new Faculty_Good_Faith_Consideration__c();
            fac.Contract__c = con.Id;
            fac.Course_Section__c = con.Course_Section_ID__c;
            fac.AccountName__c = con.AccountId;
            fac.GFC_For_Given_Course__c = true;
            insert fac;
                                    

    }


    public static testmethod void test_GFCexecute() {
        // Implement test code
        List<Contract> conLst = new List<Contract>();
        Database.BatchableContext bc;
        Test.startTest();
        
        try {
            conLst =[Select Id,name,Status,Course_Section_Status__c,Course_Section_ID__c,AccountId from Contract];
            
            FacultyearnGFCBatch gfcBatch = new FacultyearnGFCBatch();           
            Database.executeBatch(gfcBatch);
            
            gfcBatch.execute(bc,conLst);            

        } catch(Exception ex) {
            System.debug(ex.getMessage());
        }       

        Test.stopTest();

        System.assert(conLst[0].Status=='Activated');
        System.assert(conLst[0].Course_Section_Status__c=='Cancelled');
        


    }

    
    public static testmethod void testStart() {
        List<Faculty_Good_Faith_Consideration__c> facl = new List<Faculty_Good_Faith_Consideration__c>();
        Database.BatchableContext bc;
        Test.startTest();

        facl =[Select id,name,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c];
        FacultyearnGFCBatch gfcBatch = new FacultyearnGFCBatch();
        gfcBatch.start(bc);

        Test.stopTest();
        System.assert(facl[0].Id!=null);


    }   
    
    
}
I have a batch apex class and a test class. But im getting only 60% of code coverage please help me to get above 75%

Class:

global class FacultyearnGFCBatch implements Database.Batchable<sObject>


    
    global Database.QueryLocator start(Database.BatchableContext bc)
    { 
       integer year = system.today().year();
        string str1 = (year-1)+'-'+(year);
        string Campus1 = 'Boston';
        string Campus2 = 'BRD';
        string Campus3 = 'BOS';
        string inputCampus1 = '\''+'%'+ Campus1+'%'+'\'';
        string inputCampus2 = '\''+'%'+ Campus2+'%'+'\'' ;
        string inputCampus3 = '\''+'%'+ Campus3+'%'+'\'' ;
        String[] Str = new string[]{str1};
        string result = '\''+String.join(Str,'\',\'')+'\'';    
        string Class1 = 'No Payment for this Class';
        string Class2 = '\''+'%'+ Class1+'%'+'\'';
        
        
        
Id strFacultyTeachingAssignment = NEUSFIDHelper.retrieveRecordTypeId(APIPConstants.REC_TYPE_FACULTY_TEACHING_ASSIGNMENT, 'Contract');
string query1 = 'SELECT id,Account.Name,Cancelation_Fee_Scheduled__c,Canceled_Contract_Fee__c,Course_Section_ID__r.course_section_status__c,Compensation_Rate__r.name,Course_Section_ID__c,AccountId FROM Contract WHERE ';
query1=query1+'RecordType.Id IN('+'\''+strFacultyTeachingAssignment+'\''+')';
query1=query1+'AND Cancelation_Fee_Scheduled__c = True ';
query1=query1+'AND Course_Section_ID__r.course_section_status__c = \'Cancelled\' ';
query1=query1+'AND  Canceled_Contract_Fee__c  IN ( \'100% GFC Fee\',\'75% GFC Fee\') ';
query1=query1+'AND (NOT Compensation_Rate__r.name like '+Class2+')';


List<Contract> cancContractLst = Database.query(query1);
        
    string query2 = 'SELECT ID,Account.Name,AccountId,Course_Sections__c,Course_Section_ID__c,Account.Faculty_Employment_Status__pc,Account.CPS_faculty_type__pc,Campus__c,Academic_Year__c,Term__c,Account.Union_Member__c,Account.NU_Id__c,Status From Contract  WHERE ' ;
    query2=query2+'RecordType.Id IN('+'\''+strFacultyTeachingAssignment+'\''+')';
    query2=query2+'AND  Academic_Year__c IN ('+result+')';
    query2=query2+'AND Status = \'Activated\'';
    query2=query2+'AND Account.Union_Member__c = True ';
    query2=query2+'AND Account.Faculty_Employment_Status__pc = \'Active\'';
    query2=query2+'AND Account.CPS_faculty_type__pc NOT IN ( \'Full Time Faculty\',\'Half Time Faculty\') ';
    query2=query2+'AND (Campus__c Like '+inputCampus1+'OR Campus__c Like '+inputCampus2+'OR Campus__c Like '+inputCampus3+')';
   
     List<Contract> activeContractLst = Database.query(query2);

    List<Id> contractLst = new List<Id>();
      for(Contract c2 : activeContractLst) {
            contractLst.add(c2.Id);
        }
        for(Contract c1 : cancContractLst) {
            contractLst.add(c1.Id);
        }
        
    List<Faculty_Good_Faith_Consideration__c> facLst = [Select id,name,Contract__c,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c where Contract__c IN : contractLst];
    List<Id> idList = new List<Id>();
    List<Faculty_Good_Faith_Consideration__c> updateAboutlst = new List<Faculty_Good_Faith_Consideration__c>();

    for(Faculty_Good_Faith_Consideration__c fac : facLst) {
          if(fac.Course_Section__r.Course_Section_Status__c == 'Cancelled') {
            Faculty_Good_Faith_Consideration__c gc = new Faculty_Good_Faith_Consideration__c(id=fac.Id);
            gc.Accepted_Buyout__c = true;
            gc.GFC_For_Given_Course__c = false;
              updateAboutlst.add(gc);
          }
          idList.add(fac.Contract__c);          
    }

    if(updateAboutlst.size()>0)
      update updateAboutlst;

    Set<Id> newConSet = new Set<Id>(contractLst);
    Set<Id> exConSet = new Set<Id>(idList);
    List<Id> dupes = new List<Id>();
    for(Id ct : newConSet) {
      if(exConSet.contains(ct)) {
        dupes.add(ct);
      }
    }
    newConSet.removeAll(dupes);

    String query = 'Select id,Account.Name,AccountId,Course_Sections__c,Course_Section_Status__c,Course_Section_ID__c,Account.Faculty_Employment_Status__pc,Account.CPS_faculty_type__pc,Campus__c,Academic_Year__c,Term__c,Account.Union_Member__c,Account.NU_Id__c,Cancelation_Fee_Scheduled__c,Canceled_Contract_Fee__c,Status,Compensation_Rate__r.name from Contract where ID IN';
            query = query + ' :newConSet';
     
        return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext bc, List<Contract> scope)
    {                 
        list<Contract> updateContractList  = new list<Contract>();
        list<Faculty_Good_Faith_Consideration__c> gfcLst = new List<Faculty_Good_Faith_Consideration__c>();
        List<Faculty_Good_Faith_Consideration__c>  updategfcLst = new List<Faculty_Good_Faith_Consideration__c>();
        Map<id,String> gfcCancelled = new Map<id,String>();
        
        for(Contract Con : scope)
        {          

          if(con.Status == 'Activated'){

          Faculty_Good_Faith_Consideration__c facl = new Faculty_Good_Faith_Consideration__c();
             facl.Name   = con.Account.Name ;
             facl.Contract__c = con.Id;
             facl.Course_Section__c = con.Course_Section_ID__c;
             facl.AccountName__c  = con.AccountId;
             facl.GFC_For_Given_Course__c  = True;
           gfcLst.add(facl);
             
        }  
        
        if(con.Course_Section_Status__c == 'Cancelled') {            
             gfcCancelled.put(con.Id,con.Course_Section_ID__c);             
        }
      
      }           
          
            
        try {         
              if(gfcLst.size()>0)
                insert gfcLst;

              if(gfcCancelled.size()>0) {
                 List<Faculty_Good_Faith_Consideration__c> gfcCancLst = [Select id,name,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c where Course_Section__c IN :gfcCancelled.values()];
                    
                   for(Faculty_Good_Faith_Consideration__c gfcCanc: gfcCancLst) {
                   
                   Faculty_Good_Faith_Consideration__c gf = new Faculty_Good_Faith_Consideration__c(id = gfcCanc.Id);
                   gf.Accepted_Buyout__c  = True;
                   gf.GFC_For_Given_Course__c = false;
                   updategfcLst.add(gf);
                   
                   }
                }
              if(updategfcLst.size()>0) {
              database.SaveResult[] srlist = database.update(updategfcLst,false);             

              for(database.SaveResult sr : srlist)
              {
                  if(sr.isSuccess())
                  {
                      system.debug('Successfully updated GFC Records:'+sr.getId());
                  } 
                  else
                  {                         
                      for(database.Error err : sr.getErrors())
                      {
                          system.debug(err.getStatusCode()+':'+err.getMessage());
                      }
                         
                   }
                  }                                                     
               }
               
           }catch(Exception e){
                System.debug(e.getMessage());
            }   
     }       
    global void finish(Database.BatchableContext BC)
    {
       
    }
}
------------------------------------------------------------------------------------------------------------------------------------------------------------
Test Class:


@isTest
public class FacultyearnGFCBatchTest {      

    @TestSetup
    public static void setup() {    
    
    Id CPS_ACCOUNT_REC_TYPE = NEUSFIDHelper.retrieveRecordTypeId(CPSConstants.REC_TYPE_ACCOUNT_APPLICANT, 'Account');
    Id TEACHING_ASSIGNMENT_REC_TYPE = NEUSFIDHelper.retrieveRecordTypeId(CPSConstants.FACULTY_TEACHING_ASSIGNMENT_RECORD_TYPE_NAME, 'Contract');

     Account acc = new Account(FirstName = 'Novak', LastName = 'Djokovic', CPS_faculty_type__pc = 'Lecturer' ,Faculty_Employment_Status__pc ='Active', Union_Member__c = true, NU_ID__c = '1112229', RecordTypeId = CPS_ACCOUNT_REC_TYPE);
     insert acc;
     Term__c term = 
       new Term__c(
                        Name = 'Winter 2022 CPS Quarter',
                        Term_External_Id__c = '006A',
                        Academic_Year__c = '2022');
       insert term;

       Part_of_Term__c partofTerms =
       new Part_of_Term__c(
                    Name = '8',
                        Term__c = term.Id,
                         Short_Name__c = 'Spring 2022, First Six-week Session',
                         Part_of_Term_External_Id__c = 'A10008',
                        Start_Date_Part_of_Term__c = Date.parse('4/1/2022'));
       insert partofTerms;


         Course_Catalog__c courseCatalog = 
            new Course_Catalog__c(Name = 'cat-1');

         insert courseCatalog;

          Course_Section__c cSec = new Course_Section__c(
                        Name = '202215-80001',
                        CRN__c = '80001',
                        Course_Catalog__c = courseCatalog.id,
                        Part_of_Term__c = partofTerms.Id,
                        Credit_Hours__c = 3,
                        Payroll_Actual_Enrollment__c = 0,
                        Course_Section_Status__c  = 'Active');
          insert cSec;

           Compensation_Rate__c compensationRate =
           new Compensation_Rate__c(
                        Name = 'No Payment for this Class',
                        RecordTypeId = CPSCompensationRateUtil.getRecordTypeId('Base Contract Pay'),
                        Rate_Type__c = 'Flat Amount',
                        Amount__c = 8000);
           insert compensationRate;
           Contract contract =null;
                    contract = new Contract(
                    AccountId = acc.Id,
                    Academic_Year__c = '2018-2019',
                    Is_Canceled__c = false,
                    StartDate = Date.newInstance(2018, 10, 10),
                    RecordTypeId = TEACHING_ASSIGNMENT_REC_TYPE,
                    Course_Section_ID__c = cSec.id,
                    Type__c = 'Primary',
                    Status = 'Draft',
                    Campus__c = 'Boston',
                    Canceled_Contract_Fee__c = '100% GFC Fee',
                    Compensation_Rate__c = compensationRate.id);
            insert contract;
            
            Course_Section__c cs = new Course_Section__c(Id=cSec.Id);
            cs.Course_Section_Status__c ='Cancelled';
            update cs;

            Contract con = new Contract(Id = contract.Id);
            con.Status ='Activated';
            update con;

            Faculty_Good_Faith_Consideration__c fac = new Faculty_Good_Faith_Consideration__c();
            fac.Contract__c = con.Id;
            fac.Course_Section__c = con.Course_Section_ID__c;
            fac.AccountName__c = con.AccountId;
            fac.GFC_For_Given_Course__c = true;
            insert fac;
                                    

    }


    public static testmethod void test_GFCexecute() {
        // Implement test code
        List<Contract> conLst = new List<Contract>();
        Database.BatchableContext bc;
        Test.startTest();
        
        try {
            conLst =[Select Id,name,Status,Course_Section_Status__c,Course_Section_ID__c,AccountId from Contract];
            
            FacultyearnGFCBatch gfcBatch = new FacultyearnGFCBatch();           
            Database.executeBatch(gfcBatch);
            
            gfcBatch.execute(bc,conLst);            

        } catch(Exception ex) {
            System.debug(ex.getMessage());
        }       

        Test.stopTest();

        System.assert(conLst[0].Status=='Activated');
        System.assert(conLst[0].Course_Section_Status__c=='Cancelled');
        


    }

    
    public static testmethod void testStart() {
        List<Faculty_Good_Faith_Consideration__c> facl = new List<Faculty_Good_Faith_Consideration__c>();
        Database.BatchableContext bc;
        Test.startTest();

        facl =[Select id,name,Course_Section__r.Course_Section_Status__c from Faculty_Good_Faith_Consideration__c];
        FacultyearnGFCBatch gfcBatch = new FacultyearnGFCBatch();
        gfcBatch.start(bc);

        Test.stopTest();
        System.assert(facl[0].Id!=null);


    }   
    
    
}
can someone help me to cover code 100%. I'm getting 66% for my test class.
Apex class:
global class ValidateBusinessHours implements Process.Plugin { 

global Process.PluginResult invoke(Process.PluginRequest request) { 
        
        DateTime dt = (DateTime) request.inputParameters.get('dt');
        
        BusinessHours bh = [SELECT Id,name FROM BusinessHours WHERE Name='Zelle Flow' limit 1];
        System.debug('Business Hours:'+bh);
        System.debug('Current Date Time'+dt);
        System.debug('Current Date time is in Business hours::'+BusinessHours.isWithin(bh.id, dt));
        Map<String,boolean> result = new Map<String,boolean>(); 
        result.put('value',BusinessHours.isWithin(bh.id, dt));
        return new Process.PluginResult(result);
    } 

    // Returns the describe information for the interface
    global Process.PluginDescribeResult describe() { 
        Process.PluginDescribeResult result = new Process.PluginDescribeResult(); 
        result.Name = 'businessHoursplugin';
        result.Tag = 'BusinessHours';
        result.inputParameters = new 
           List<Process.PluginDescribeResult.InputParameter>{ 
               new Process.PluginDescribeResult.InputParameter('dt', 
               Process.PluginDescribeResult.ParameterType.DateTime, true)
            };
         result.outputParameters = new 
           List<Process.PluginDescribeResult.OutputParameter>{
            new Process.PluginDescribeResult.OutputParameter(
                'value', 
                Process.PluginDescribeResult.ParameterType.boolean)
           };     
        return result; 
    }
}




Test Class:

@isTest
private class ValidateBusinessHours_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    BusinessHours businesshours_Obj = new BusinessHours(Name = 'Name220', IsActive = true, IsDefault = false, TimeZoneSidKey = 'Pacific/Kiritimati');
    test.stopTest();
  }
  static testMethod void test_PluginRequest_UseCase1(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    //obj01.PluginRequest(new Process.PluginRequest());
    
  }
  static testMethod void test_describe_UseCase1(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    obj01.describe();
  }

    static testMethod void test_describe_UseCase2(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    //businesshours_Obj[0].id='';
    businesshours_Obj[0].Name='hgvhv';
    obj01.describe();
  }
}
 
hi everyone,
I have created a registration page where we have to give details along with username and password for it, and login page with username and password fields.
For username and password fields in login page i have binded the values from registration page.
And i have created multiple registrations with different username and passwords.
In login page every username and password is working but after login it is showing all the registered user details.
I have "my account details" page in which it displays all the registered users details.
I want only the details of logged user.
I'm integrating Salesforce to other application(Ruby). I'm able to sync data both ways. But while updating data from Application to salesforce, every time i have to provide access token. So is there any way to get a permanent Access token?
Thank You..
I covered 40% with the below test class. Help me to cover 75%.
Apex Class:
public class FFQExt 
{
Public attachment objAttachment
{
get
{
if (objAttachment == null)
objAttachment = new Attachment();
return objAttachment ;
}
set;
}
public Id recordId {get; set;}
Public FFQ__C l{get; set;}
public String currentRecordId {get;set;}
public FFQExt(ApexPages.StandardController stdCon) 
{
currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
this.recordId = stdCon.getId();
this.l = (FFQ__c)stdCon.getRecord();  
objAttachment = new Attachment();
l = new FFQ__c();
l = [select Name, id, Business_Address__c, Business_Phone_Number__c, City__c, Client__c, Corporate_Structure__c, County__c, CPA_Contact__c, CPA_Contact_Email__c, 
CPA_Contact_Name__c, CPA_Contact_Phone__c, Do_you_ever_rehire_employees__c, MultipleEIN__c, Do_you_have_plans_for_Future_Expansion__c, Do_you_have_Recent_Expansion__c,
EIN__c, Estimated_Date_of_Tax_Filing__c, estimated_number_of_employees_hired_per__c, Executive_Contact__c, Executive_Contact_Email__c, Executive_Contact_Name__c,
Executive_Contact_Phone__c, Federal_Empowerment_Zone_Wage_Credit__c, First_Name__c, First_NameofPerson__c, Fiscal_Year_End_Date__c, General_Tax_Status__c, 
How_many_current_employees_do_you_have__c, How_many_W2s_were_distributed_last_year__c, HR_Contact__c, HR_Contact_Email__c, HR_Contact_Name__c, HR_Contact_Phone__c,
HR_Platform_to_onboard_your_Employees__c, Indian_Employment_Tax_Credit__c, Invoice_Contact__c, Invoice_Contact_Email__c, Invoice_Contact_Name__c, Invoice_Contact_Phone__c,
Legal__c, Is_your_business_Seasonal__c, I_understand__c, Last_Name__c, Last_NameofPerson__c, Legal_Address__c, Legal_City__c, Legal_County__c, Legal_Entity_Name__c, Legal_State__c,
Legal_Zip__c, list_all_locations_worksites__c, Payroll_Contact__c, Payroll_Contact_Email__c, Payroll_Contact_Name__c, Payroll_Contact_Phone__c, Please_list_all_EIN_Legal_Entities_below__c, 
Primary_Contact_Email__c, Primary_Contact_Number__c, Primary_Contact_Title__c, State__c, States_State_IDs_with_Tax_Liability__c, State_Specific_Incentives__c, To_begin_participation__c,
Which_HR_Platform_are_you_utilizing__c, Which_Payroll_Provider_are_you_using__c, WOTC__c, Zip__c from FFQ__c where id =: currentRecordId ];

}
Public void dosave()
{
if(objAttachment.body == null) 
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please upload your Documents'));
return ApexPages.CurrentPage();
}
else
{
upsert l;
objAttachment.ParentId = l.id;
try 
{
upsert objAttachment;
}
catch (DMLException e) 
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error Submitting Form'));
return null;
}
finally
{
objAttachment.body = null; // clears the viewstate
objAttachment = new Attachment();
}
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Form Submitted Successfully'));
 PageReference mypage = new PageReference('/apex/thankyou');
   mypage.setRedirect(true);
   return mypage;
return null;
}
}
}
Test Class:
 
@isTest
private class FFQExt_Test1{
  @testSetup
  static void setupTestData(){
    test.startTest();
    FFQ__c ffq_Obj = new FFQ__c(Name = 'Name714', First_Name__c = 'First917', Last_Name__c = 'Last_775', Primary_Contact_Title__c = 'Prima305', Primary_Contact_Email__c = 'Email16@test.com', Primary_Contact_Number__c = '54343-6724', Business_Address__c = '18', City__c = 'City__c632', State__c = 'Alabama', Zip__c = 'Zip__c497', Business_Phone_Number__c = '54343-92658', Legal_Entity_Name__c = 'Legal220', Legal__c = false, EIN__c = 25, MultipleEIN__c = false, Please_list_all_EIN_Legal_Entities_below__c = '27', list_all_locations_worksites__c = '28', Corporate_Structure__c = 'C-Corp', Estimated_Date_of_Tax_Filing__c = Date.today(), General_Tax_Status__c = 'Paying Regular Tax', Fiscal_Year_End_Date__c = Date.today(), States_State_IDs_with_Tax_Liability__c = '33', Do_you_have_Recent_Expansion__c = false, Do_you_have_plans_for_Future_Expansion__c = false, Executive_Contact_Name__c = 'Execu607', Executive_Contact_Email__c = 'Email37@test.com', Executive_Contact_Phone__c = '54343-11689', CPA_Contact_Name__c = 'CPA_C106', CPA_Contact_Phone__c = '54343-93693', CPA_Contact_Email__c = 'Email41@test.com', HR_Contact_Name__c = 'HR_Co140', HR_Contact_Email__c = 'Email43@test.com', HR_Contact_Phone__c = '54343-70632', Invoice_Contact_Name__c = 'Invoi739', Invoice_Contact_Email__c = 'Email46@test.com', Invoice_Contact_Phone__c = '54343-50578', Payroll_Contact_Name__c = 'Payro557', Payroll_Contact_Email__c = 'Email49@test.com', Payroll_Contact_Phone__c = '54343-67706', HR_Platform_to_onboard_your_Employees__c = 'Yes', Which_HR_Platform_are_you_utilizing__c = 'Which567', Which_Payroll_Provider_are_you_using__c = 'Which997', How_many_current_employees_do_you_have__c = 54, How_many_W2s_were_distributed_last_year__c = 55, estimated_number_of_employees_hired_per__c = 'estim415', Is_your_business_Seasonal__c = 'Is_yo660', Do_you_ever_rehire_employees__c = 'Do_yo497', First_NameofPerson__c = 'First430', Last_NameofPerson__c = 'Last_585', Legal_Address__c = '61', Legal_City__c = 'Legal521', Legal_Zip__c = 63, Legal_State__c = 'Alabama', WOTC__c = false, State_Specific_Incentives__c = false, Federal_Empowerment_Zone_Wage_Credit__c = false, Indian_Employment_Tax_Credit__c = false, Executive_Contact__c = false, CPA_Contact__c = false, HR_Contact__c = false, Invoice_Contact__c = false, Payroll_Contact__c = false, To_begin_participation__c = '74', County__c = 'Count208', Legal_County__c = 'Legal590', I_understand__c = 'Yes');
    Insert ffq_Obj; 
    test.stopTest();
  }
  static testMethod void test_dosave_UseCase1(){
    List<FFQ__c> ffq_Obj  =  [SELECT Id,Name,First_Name__c,Last_Name__c,Primary_Contact_Title__c,Primary_Contact_Email__c,Primary_Contact_Number__c,Business_Address__c,City__c,State__c,Zip__c,Business_Phone_Number__c,Legal_Entity_Name__c,Legal__c,EIN__c,MultipleEIN__c,Please_list_all_EIN_Legal_Entities_below__c,list_all_locations_worksites__c,Corporate_Structure__c,Estimated_Date_of_Tax_Filing__c,General_Tax_Status__c,Fiscal_Year_End_Date__c,States_State_IDs_with_Tax_Liability__c,Do_you_have_Recent_Expansion__c,Do_you_have_plans_for_Future_Expansion__c,Executive_Contact_Name__c,Executive_Contact_Email__c,Executive_Contact_Phone__c,CPA_Contact_Name__c,CPA_Contact_Phone__c,CPA_Contact_Email__c,HR_Contact_Name__c,HR_Contact_Email__c,HR_Contact_Phone__c,Invoice_Contact_Name__c,Invoice_Contact_Email__c,Invoice_Contact_Phone__c,Payroll_Contact_Name__c,Payroll_Contact_Email__c,Payroll_Contact_Phone__c,HR_Platform_to_onboard_your_Employees__c,Which_HR_Platform_are_you_utilizing__c,Which_Payroll_Provider_are_you_using__c,How_many_current_employees_do_you_have__c,How_many_W2s_were_distributed_last_year__c,estimated_number_of_employees_hired_per__c,Is_your_business_Seasonal__c,Do_you_ever_rehire_employees__c,First_NameofPerson__c,Last_NameofPerson__c,Legal_Address__c,Legal_City__c,Legal_Zip__c,Legal_State__c,WOTC__c,State_Specific_Incentives__c,Federal_Empowerment_Zone_Wage_Credit__c,Indian_Employment_Tax_Credit__c,Executive_Contact__c,CPA_Contact__c,HR_Contact__c,Invoice_Contact__c,Payroll_Contact__c,To_begin_participation__c,County__c,Legal_County__c,I_understand__c from FFQ__c];
    System.assertEquals(true,ffq_Obj.size()>0);
    PageReference pageRef = Page.FFQ;
    pageRef.getParameters().put('id','test');
    Test.setCurrentPage(pageRef);
    FFQExt obj01 = new FFQExt(new ApexPages.StandardController(ffq_Obj[0]));
    obj01.objAttachment = new attachment();
    obj01.recordId = '01p90000006uk2w';
    obj01.l = ffq_Obj[0];
    obj01.currentRecordId = 'test data';
    obj01.dosave();
  }
}


 
Below is my code:

Location__c loc = [SELECT Id,Name,Company__r.company_id__c,Location_Address__c,Location_City__c,Location_Zip__c,Location_State__c,Location_Participation_Method__c from Location__c where id = 'a0P2C000001KkEa'] ;  
JSONGenerator gen = JSON.createGenerator(true);  
    Decimal companyID = loc.Company__r.Company_id__c;


    gen.writeStartObject();      
    gen.writeStringField('location_name',loc.name);
    system.debug(loc.Company__r.company_id__c);
    system.debug('https://api-qa.retrotax-aci.com/companies/'+CompanyID+'/locations');
    // gen.writeStringField('Company_id',String.valueOf(loc.Company__r.company_id__c));
    gen.writeStringField('address_line_1',loc.Location_Address__c);
    gen.writeStringField('sf_id',loc.id);
    gen.writeStringField('city',loc.Location_City__c );
    gen.writeStringField('zip_code',loc.Location_Zip__c );
    gen.writeStringField('state_code',loc.Location_State__c);
    gen.writeSrtingField('participation_methods', loc.Location_Participation_Method__c); 
gen.writeEndObject();    
    String jsonS = gen.getAsString();
System.debug('Location Data'+jsonS);

Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://api-qa.retrotax-aci.com/companies/'+CompanyID+'/locations');
request.setMethod('POST');
request.setHeader('X-AUTH-TOKEN','xxxxxxxxxxx);
request.setHeader('X-API-KEY', 'xxxxxxxxxxxx');
request.setHeader('Content-Type', 'application/json;charset=UTF-8');
// Set the body as a JSON object
request.setBody(jsonS );
HttpResponse response = http.send(request);
// Parse the JSON response
if (response.getStatusCode() == 200) {
Location__c result = (Location__c) JSON.deserialize(response.getBody(), Location__c.class);
System.debug('Location:'+result.id);
loc.Location_Id__c = Decimal.valueOf(result.id);
update loc;

    System.debug('Location Created Successfully: ' +
        response.getStatusCode() + ' ' + response.getBody());
} else {
    System.debug('Unable to create Location: ' +
        response.getStatusCode() + ' ' + response.getBody());
     
}

Here "Loaction_Participation_method__c"  is MutliSelect Picklist.
i need to get these values in array format i.e. (["Combo","Paper"]).
below is my result:
User-added image
Hi All,

I have picklist component with 5 (A,B,C,D,E) values. and my requirement is when user select A or B then it will redirect to  the new VF page else it will remain on same page for other Values selection.

Thanks,
Anish
I have two screens (Screen1, Screen2) in a Flow. If Current Time Equals to Business Hours Time It should disply Screen1 else it Should Display Screen2. But it is Displaying only either Screen1 or Screen2. Please Help... 
can someone help me to cover code 100%. I'm getting 66% for my test class.
Apex class:
global class ValidateBusinessHours implements Process.Plugin { 

global Process.PluginResult invoke(Process.PluginRequest request) { 
        
        DateTime dt = (DateTime) request.inputParameters.get('dt');
        
        BusinessHours bh = [SELECT Id,name FROM BusinessHours WHERE Name='Zelle Flow' limit 1];
        System.debug('Business Hours:'+bh);
        System.debug('Current Date Time'+dt);
        System.debug('Current Date time is in Business hours::'+BusinessHours.isWithin(bh.id, dt));
        Map<String,boolean> result = new Map<String,boolean>(); 
        result.put('value',BusinessHours.isWithin(bh.id, dt));
        return new Process.PluginResult(result);
    } 

    // Returns the describe information for the interface
    global Process.PluginDescribeResult describe() { 
        Process.PluginDescribeResult result = new Process.PluginDescribeResult(); 
        result.Name = 'businessHoursplugin';
        result.Tag = 'BusinessHours';
        result.inputParameters = new 
           List<Process.PluginDescribeResult.InputParameter>{ 
               new Process.PluginDescribeResult.InputParameter('dt', 
               Process.PluginDescribeResult.ParameterType.DateTime, true)
            };
         result.outputParameters = new 
           List<Process.PluginDescribeResult.OutputParameter>{
            new Process.PluginDescribeResult.OutputParameter(
                'value', 
                Process.PluginDescribeResult.ParameterType.boolean)
           };     
        return result; 
    }
}




Test Class:

@isTest
private class ValidateBusinessHours_Test{
  @testSetup
  static void setupTestData(){
    test.startTest();
    BusinessHours businesshours_Obj = new BusinessHours(Name = 'Name220', IsActive = true, IsDefault = false, TimeZoneSidKey = 'Pacific/Kiritimati');
    test.stopTest();
  }
  static testMethod void test_PluginRequest_UseCase1(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    //obj01.PluginRequest(new Process.PluginRequest());
    
  }
  static testMethod void test_describe_UseCase1(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    obj01.describe();
  }

    static testMethod void test_describe_UseCase2(){
    List<BusinessHours> businesshours_Obj  =  [SELECT Id,Name from BusinessHours];
    System.assertEquals(true,businesshours_Obj.size()>0);
    ValidateBusinessHours obj01 = new ValidateBusinessHours();
    //businesshours_Obj[0].id='';
    businesshours_Obj[0].Name='hgvhv';
    obj01.describe();
  }
}
 
Hi friends...
Am struggling to write Test class for below code for Getting Lead...please help me t's urgent..



public static Lead getLead(String recordId) {
  Lead lead = [Select id,Status,Status__c  from Lead where id=:recordId]; 
  return lead;
    } 



Thanks
Chandu

So, I have the code running to create the .xfdf and attach it to the proper account.  Everything looked perfect, until I went to open my file.  Instead of the .xfdf opening and overlaying the online form, it instead downloads a new copy of itself.  Is there an issue in my xlm?  What am I doing wrong here.  Below is the code, and I have verified the .xfdf's are coming out correctly.

 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
public with sharing class CreateIO {

    DateTime nowDT=System.now();
    String formatted=nowDT.format('MM-dd-yyyy');

private String getXmlString(JJSale__c a)
{

    
    String s = '<?xml version="1.0" encoding="UTF-8"?>' +
        '<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' +
        '<f href="https://na11.salesforce.com/resource/1300398748000/IO_JJ"/>' +
        '<fields>' +
        '<field name="Acct Rep"><value>' + a.CreatedBy.Name + '</value></field>' +
        '<field name="Ad Cost"><value>' + a.Ad_Price__c + '</value></field>' +
        '<field name="Address"><value>' + a.Organization__r.BillingStreet + '</value></field>' +
        '<field name="Advertiser"><value>' + a.Organization__r.Name + '</value></field>' +
        '<field name="Bill to"><value>x</value></field>' +
        '<field name="City"><value>' + a.Organization__r.BillingCity + '</value></field>' +
        '<field name="Contact"><value>' + a.Contact__r.Name + '</value></field>' +
        '<field name="Date"><value>' + formatted + '</value></field>' +
        '<field name="Email"><value>' + a.Contact__r.Email + '</value></field>' +
        '<field name="Fax"><value>' + a.Contact__r.Fax + '</value></field>' +
        '<field name="INSERTION DATES AND NOTES 1"><value>' + a.Journal_Issue__r.Name + '</value></field>' +
        '<field name="INSERTION DATES AND NOTES 2"><value>' +
            a.Page_Requested__c + ', ' + a.Insertion_Notes__c + '</value></field>' +
        '<field name="Phone"><value>' + a.Contact__r.Phone + '</value></field>' +
        '<field name="State"><value>' + a.Organization__r.BillingState + '</value></field>' +
        '<field name="Todays Date"><value>' + formatted + '</value></field>' +
        '<field name="Zip"><value>' + a.Organization__r.BillingPostalCode + '</value></field>' +
        '</fields><ids original="CB86FA72BFC7A2744D5052A67D1686EE" modified="C0A949601A5BB74AB94C1DAA08D65D2F"/>' +
        '</xfdf>';
        
    return s;
}

public PageReference XFDFInit()
{
    JJSale__c a = [SELECT Id, CreatedBy.Name, Ad_Price__c, Organization__r.BillingStreet, Organization__r.Name,
                         Organization__r.BillingCity, Contact__r.Name, Contact__r.Email, Contact__r.Fax,
                         Journal_Issue__r.Name, Page_Requested__c, Insertion_Notes__c, Contact__r.Phone,
                         Organization__r.BillingState, Organization__r.BillingPostalCode
                         FROM JJSale__c
                         WHERE id = :ApexPages.currentPage().getParameters().get('id')];
    String xmlContent = getXmlString(a);
    
    Attachment attachment = new Attachment();
        attachment.Body = Blob.valueof(xmlContent);
        attachment.Name = a.Organization__r.Name + '_' + formatted + '.XFDF';
        attachment.ParentId = a.Organization__r.Id;
        insert attachment;
    
    PageReference orgPage = new PageReference('/' + a.Organization__r.id);
    orgPage.setRedirect(true);
    return orgPage;
}

}