• sfuser12
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 11
    Replies
I want to write a apex class- API calls to create this -
https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/retrieve_a_subscriber_via_the_web_service_api.htm

How can I make use of this in apex?

Hi, 

I am not able to cover this class. Can anybody help me?

public class fileImport {
    public Blob fileBody;
    public String fileName;
    public String templateName;
    public String careProgram;
    public Date fileDate;
    public String importName;
}

Thanks!
 
Hello,

I have give permission to particular group to convert lead assigned to them. By default they has all access on account and contact. I want they should edit account on lead conversion but other times they can not edit account. How is this possible through validation rule.

Thanks!
Hello,

I want to show Name field based on selected rating. Like if I select rating = hot then it should show name of that rating which is hot.

Rating will be input field. Name will be output field

<apex:page id="dependentvalueVF" controller="dependentvalueController" docType="html-5.0"> <apex:form>
<apex:actionFunction action="{!yourControllerMethod}" name="callTemplate"/>
<apex:pageblock>
<apex:pageBlockSection>
<apex:inputfield label="Rating" value="{!locationList.Rating}" onChange="callTemplate" />
<apex:outputField label="Name" value="{!locationList.Name}"/> </apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>

public with sharing class dependentvalueController {
public Account locationList{get;set;}
public string Rating{get;set;}
public string Name {get;set;}
public PageReference yourControllerMethod(){
locationList = [Select Name From Account Where Rating =:Rating LIMIT 1];
return null;
}
}
 

I am not able to cover test class. I am getting error in assert statement. It return status = new.
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases1' + updateCases); this is also null.
Can anyone suggest how to cover this test class?


Class: 
public static final String Query_To_Word_Services = 'Word Services';
public static final String Query_Reason_Turnover = 'Turnover';
public static final String Priority_7_Internal = '7-Internal';
public static final String Status_Resolved = 'Resolved';
public static final String Job_WS_Production_Stage_Completed = 'Completed';
public static Id queryRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Query').getRecordTypeId();
        Set<Id> completedJobsIds = new Set<Id>();
        for (Job__c job : newJobs) {
            if (job.WS_Production_Stage__c == 'Completed') {
                completedJobsIds.add(job.id);
            }
        }
        System.debug('CaseAssignmentRuleHelper.resolveCases completedJobsIds' + JSON.serialize(completedJobsIds));

        List<Case> updateCases = [
                SELECT Id, Status
                FROM Case
                WHERE Job__c IN:completedJobsIds
                AND recordtypeId = :queryRecordTypeId
                AND Query_To__c = :Query_To_Word_Services
                AND Query_Reason__c = :Query_Reason_Turnover
                AND Priority = :Priority_7_Internal
                AND Status != :Status_Resolved
        ];
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases1' + updateCases);

        for (Case updateCase : updateCases) {
            updateCase.Status = Status_Resolved;
        }
        if (!updateCases.isEmpty()) {
            update updateCases;
        }
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases' + JSON.serialize(updateCases));
    }

Test Class: 
  //Create account
        Account testAccount = TestUtilities.CreateAccount('testAcc', false);
        Insert testAccount;

        //Create contact
        Contact testContact = TestUtilities.CreateContact('testCon', testAccount, true);

        //Create opportunity
        Opportunity testOpportunity = TestUtilities.CreateOpportunity(testAccount, 'testOpp', true);

        //Create project
        Project__c testProject = TestUtilities.CreateProject('testPrj', testAccount, testOpportunity, false);
        testProject.Project_Type__c = 'Live';
        testProject.Form_Type__c = '10-K';
        testProject.Filing_Date__c = datetime.now();
        testProject.Account__c = testAccount.ID;
        testProject.Opportunity__c = testOpportunity.ID;
        Insert testProject;

        //Create job
        Job__c testJob = new Job__c();
        testJob.Job_Status__c = 'In Progress';
        testJob.Account__c = testAccount.id;
        testJob.Project_Implementation__c = testProject.ID;
        testJob.WS_Production_Stage__c = 'Completed';
        insert testJob;
        System.debug('testJob---'+testJob);

       Id queryRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Query').getRecordTypeId();

        //Create case
        Case testCase = new Case();
        testCase.RecordTypeId = queryRecordTypeId;
        testCase.Query_To__c = 'Word Services';
        testCase.Query_Reason__c = 'Turnover';
        testCase.Priority = '7-Internal';
        testCase.Job__c = testJob.id;
        testCase.Status = 'New';
        Test.startTest();
        insert testCase;
        System.debug('testCase---: ' + testCase);
        update testJob;
        Test.stopTest();      
        
        Case testCase1 = [SELECT Status FROM Case WHERE Job__c =: testJob.id limit 1];
        System.debug('Status after trigger fired: ' + testCase1.Status);
        System.assertEquals(testCase1.Status, 'Resolved');
    }
Hello,
In my batch class execute method does not cover. Can anyone suggest me how to cover execute method.

/**
* Created by CS on 12-12-2018.
*/
public without sharing class opportunityTeamMemberBatch implements Database.Batchable<sObject>, Database.Stateful {
    public Map<Id, String> opportunitiesErrors;
    public Set<Id> processedOpportunityIds;
    public Integer totalSuccessRecords = 0;
    public Integer totalFailureRecords = 0;
    
    public opportunityTeamMemberBatch() {
        opportunitiesErrors = new Map<Id, String>();
        processedOpportunityIds = new Set<Id>();
    }
    
    public Database.QueryLocator start(Database.BatchableContext BC) {
        System.debug('opportunityTeamMemberBatch.start');
        
        String query = 'SELECT Id, TeamMemberRole, Opportunity.Opportunity_Team_Member_Aliases__c, OpportunityId '
            + ' FROM OpportunityTeamMember '
            + ' Where Opportunity.Opportunity_Team_Member_Aliases__c = null';
                System.debug('opportunityTeamMemberBatch.start query'+query);
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<OpportunityTeamMember> opportunityTeamMembers) {
        System.debug('opportunityTeamMemberBatch.execute opportunityTeamMembers'+JSON.serialize(opportunityTeamMembers));
       
        Map<Id, OpportunityTeamMember > opportunityIdtoOpportunityTeamMembers = new Map<Id, OpportunityTeamMember>();
        for (OpportunityTeamMember opportunityTeamMember : opportunityTeamMembers) {
            opportunityTeamMember.TeamMemberRole = opportunityTeamMember.TeamMemberRole;
            opportunityIdtoOpportunityTeamMembers.put(opportunityTeamMember.OpportunityId, opportunityTeamMember);
        }
        
        if (opportunityIdtoOpportunityTeamMembers != null) {
            List<Database.SaveResult> opportunityTeamMemberResults = Database.update(opportunityIdtoOpportunityTeamMembers.values(), false);
            System.debug('opportunityTeamMemberBatch.execute opportunityTeamMemberResults:' + JSON.serialize(opportunityTeamMemberResults));
            Set<Id> processedOpportunityIds = new Set<Id>();
            Integer index = 0;
                for (Id opportunityId : opportunityIdtoOpportunityTeamMembers.keySet()) {
                    Database.SaveResult saveResult = opportunityTeamMemberResults[index++];
                    
                    if (saveResult.isSuccess()) {
                        processedOpportunityIds.add(opportunityId);
                        totalSuccessRecords++;
                        System.debug('Successfully updated opportunity IDs ' + processedOpportunityIds);
                    } else {
                        opportunitiesErrors.put(opportunityId, saveResult.getErrors()[0].getMessage());
                        System.debug('Error occurred' + opportunityId + ': ' + saveResult.getErrors()[0].getMessage());
                        totalFailureRecords++;
                    }
                    index++;
            }
        }
    }
    
    public void finish(Database.BatchableContext batchableContext) {
        System.debug('opportunityTeamMemberBatch.finish');

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        AsyncApexJob asyncApexJob = [
            Select asyncApexJob.TotalJobItems, asyncApexJob.Status, asyncApexJob.NumberOfErrors,
            asyncApexJob.JobType, asyncApexJob.JobItemsProcessed, asyncApexJob.ExtendedStatus, asyncApexJob.CreatedById,
            asyncApexJob.CompletedDate
            From AsyncApexJob asyncApexJob
            WHERE id = :batchableContext.getJobId()
        ];
        
        System.debug('opportunityTeamMemberBatch.finish Job id is' + batchableContext.getJobId());
        
        String[] toAddresses = new String[]{
            'utkarsha.up10@gmail.com'
                };
                    mail.setToAddresses(toAddresses);
        mail.setSubject('Batch Processing ' + asyncApexJob.Status);
        mail.setPlainTextBody('Total Success Records ' + totalSuccessRecords
                              + '\n Total Failure Records ' + totalFailureRecords
                              + '\n Total Batch Apex job processed:' + asyncApexJob.TotalJobItems
                              + '\n Job Item processed: ' + asyncApexJob.JobItemsProcessed
                              + '\n Failures: ' + opportunitiesErrors);
        Messaging.sendEmail(new Messaging.SingleEmailMessage []{
            mail
                });
        System.debug('opportunityTeamMemberBatch.finish mail sent successfully');
    }
}

Test class

/**
* Created by CS on 12-12-2018.
*/
@IsTest
private class opportunityTeamMemberBatchTest {
    
    @testSetup static void setup() {
        Profile profile = [SELECT Id FROM Profile WHERE Name = 'Standard User'];
        
        User user = new User();
        user.Alias = 'alias';
        user.ProfileId = profile.Id;
        user.Email = 'testMemberUser@dfsco.com';
        user.EmailEncodingKey = 'UTF-8';
        user.LanguageLocaleKey = 'en_US';
        user.LocaleSidKey = 'en_US';
        user.TimeZoneSidKey = 'America/Los_Angeles';
        user.UserName = 'testMemberUser@dfsco.com';
        user.LastName = 'testLastName';
        insert user;
        
        Account account = new Account();
        account.Name = 'Test Account';
        account.CIK__c = '1234567899';
        account.BillingStateCode = 'IL';
        account.BillingCountryCode = 'US';
        account.BillingCity = 'McLean';
        insert account;
        
        Opportunity opportunity = new Opportunity();
        opportunity.Name = 'Test Opportunity';
        opportunity.AccountId = account.Id;
        opportunity.StageName = 'Propose';
        opportunity.CloseDate = Date.today();
        opportunity.CurrencyIsoCode = 'USD';
        opportunity.LeadSource = 'Auditor';
        opportunity.Business_Line__c = 'Capital Markets';
        opportunity.Product_Type_Interests__c = 'AD Partner Product';
        insert opportunity;
        
        OpportunityTeamMember opportunityTeamMember = new OpportunityTeamMember();
        opportunityTeamMember.TeamMemberRole = 'AD Sales Team';
        opportunityTeamMember.UserId = user.Id;
        opportunityTeamMember.OpportunityId = opportunity.Id;
        insert opportunityTeamMember;
        System.debug('opportunityTeamMemberBatchTest opportunityTeamMember'+opportunityTeamMember); 
    }
    
    static testMethod void executeBatchApexTest() {
        Test.startTest();
        System.debug('executeBatchApexTest');
        opportunityTeamMemberBatch opportunityTeamMemberBatch = new opportunityTeamMemberBatch();
        Database.executeBatch(opportunityTeamMemberBatch);
        System.debug('executeBatchApexTest Database.executeBatch'+Database.executeBatch(opportunityTeamMemberBatch));
        Test.stopTest();
    }
    
    static testMethod void batchFinishMethod() {
    }
}
Hello,

How we can get accountId of deleted Account Team Member?

Thanks,
sfuser12
Hi,

I know salesforce coding. But its difiicult for me to code like java. I want to write batch class but my main logic will be in utility class.
I want to know coding structure.
My requirement is my main logic will be in utility class. So query in start method will be in utility class and I have to call it in start methid of batch class.
How we can do that? Can anybody suggest?

Thanks,
sfuser12
Hi,

I want to add custom link in lightning component instead of custom link or button.

Can any one tell how to add it in lightning component

Custom Link: https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDEfEAO/view?fv0={!Campaign.Id}

Thanks,
sfuser12
 
Hello,

I am using this code as I want same functionality- https://blogs.absyz.com/2018/07/12/custom-calendar-lightning-component/.

I did everything as mentioned. But I am getting error.
User-added image

I have copied code same as given in document. I didnt find any problem in handleclick function. ot getting what to do. Has anybody tried this before?

Thanks,
sfuser12
Hi,
I am writing test class which is 57% covered. But not getting how to cover    if (this.taskWhoId.getSobjectType() == Contact.SObjectType)

public String getNameWhoId() {
        if (String.isBlank(this.taskWhoId)) 
            return null;
        else
        if (this.taskWhoId.getSobjectType() == Contact.SObjectType)
            return [select name from Contact where id = :taskWhoId limit 1].name;
        else
            return null;
    }

Test Class:

 @TestSetup static void setup()
    {
        Account account = new Account();
        account.name='Test Account';
        account.Phone = '9872345617';
        account.Type = 'Prospect';
        account.BillingCity='Testcity';
        account.BillingStateCode='IL';
        account.BillingCountryCode='US';
        insert account;

        Contact contact = new Contact();
        contact.FirstName = 'firstName';
        contact.LastName = 'lastName';
        contact.Accountid= account.Id;
        contact.Email__c = 'xyz@testorg12.com';
        contact.MailingCity = 'Testcity';
        contact.MailingStateCode='IL';
        contact.MailingCountryCode='US';
        insert contact;

        Task task = new Task();
        task.Type = 'Email';
        task.Description = 'Test Description';
        task.OwnerId = UserInfo.getUserId();
        task.WhatId = account.Id;
        task.WhoId = contact.Id;
        task.Primary__c = 'Survey';
        task.Call_Topic__c = 'ActiveDisclosure';
        task.Status = 'New';
        task.Subject = 'Test Subject';
        task.Priority = 'Low';
        insert task;
    }

    @isTest static void testgetNameWhoId() {
        List<Task> tasks = [Select Id from task limit 1];
        CCSelfFilingTrainingController getIds = new CCSelfFilingTrainingController();
        getIds.getNameWhoId();
        getIds.getNameWhatId();

Can anyone tell me how to cover if condition in this case?
Hi there,

Is there any way to create task(activity history) using url hack send mail?

Thanks,
SFUser
 
Hello,

I am writing test class for wrapper class. I have done everything. still covergae for wrapper class in only 1%. Can anyone help?

Class:
 public void assignLeads() {
        System.debug('CFRRetentionSiteDashboardController2.assignLeads - start ' + LEAD_QUALIFICATION_CAMPAIGN + '::' + LeadSourceSelection);

        TotalNumberOfAllocatedLeads = 0;
        System.debug('CFRRetentionSiteDashboardController2.sumOfTheLeads()-agentWrappers-' + agentWrappers);
        for (UserWrapper agentUserWrapper : agentWrappers) {
            TotalNumberOfAllocatedLeads += agentUserWrapper.numberOfLeadsToAssign;
        }
        System.debug('TotalNumberOfAllocatedLeads' + TotalNumberOfAllocatedLeads);

        List<Lead> leads = getLeadsToBeAssigned();
        List<Lead> leadsToUpdate = new List<Lead>();

        Integer totalLeads = leads.size();
        System.debug('totalLeads--' + totalLeads);
        if (leads.isEmpty() || totalLeads < TotalNumberOfAllocatedLeads) {
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, 'Number of allocated leads are more than available leads.'));
        } else {
            List<UserWrapper> assignLeadsToAgents = new List<UserWrapper>();
            for (UserWrapper agentUserWrapper : agentWrappers) {
                if (agentUserWrapper.numberOfLeadsToAssign > 0) {
                    assignLeadsToAgents.add(agentUserWrapper);
                }
            }

            Integer startLeadAssignment = 0;
            for (UserWrapper agentUserWrapper : assignLeadsToAgents) {
                Integer agentLeads = agentUserWrapper.numberOfLeadsToAssign;
                for (Integer startAgentLead = 0; startAgentLead < agentLeads; startAgentLead++) {
                    Lead tmpLead = leads[startLeadAssignment];
                    tmpLead.OwnerId = agentUserWrapper.agent.Id;
                    tmpLead.Retention_Owner__c = agentUserWrapper.agent.Name;
                    if (currentSite != null) {
                        tmpLead.Retention_Site__c = currentSite.Id;
                    }
                    leadsToUpdate.add(tmpLead);
                    startLeadAssignment++;
                }
            }

            update leadsToUpdate;
            System.debug('CFRRetentionSiteDashboardController2.assignLeads-- leadsToUpdate' + leadsToUpdate);
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.CONFIRM, 'Lead Assignment has been successfully processed.'));
            refresh();

Test Class:

        Profile profile = [SELECT Id FROM Profile WHERE Name='System Administrator'];

        User user = new User(firstname = 'testUserFname',
                lastName = 'testULastname',
                email = 'testUser@test.org',
                Username = 'testUserassignleads@test.org',
                EmailEncodingKey = 'ISO-8859-1',
                Alias ='testUser',
                TimeZoneSidKey = 'America/Los_Angeles',
                LocaleSidKey = 'en_US',
                LanguageLocaleKey = 'en_US',
                ProfileId = profile.Id
        );
        insert user;

        CFRRetentionSiteDashboardController2 controller = new CFRRetentionSiteDashboardController2();
        controller.assignLeads();
       
        CFRRetentionSiteDashboardController2.UserWrapper userWrapper = new CFRRetentionSiteDashboardController2.UserWrapper(user,true);
        List<Lead> leads = controller.getLeadsToBeAssigned();
 
Hello,

I am getting error duplicate Id. Can anyone suggest what to do?
   Set<Id> leadIds = new Map<Id, Lead>([SELECT Id, OwnerId 
                                FROM Lead]).keySet();
        
        List<Lead> leads = [SELECT Id, OwnerId 
                                FROM Lead 
                                Where LeadSource =: LeadSourceSelection
                                and Owner.Name =:LEAD_QUALIFICATION_QUEUE_NAME 
                                and Id=:leadIds
                           ];
        
        List<Lead> leadsToUpdate=new List<Lead>();
        
        for( UserWrapper agentUserWrapper : agentWrappers ) {            
            System.debug('CFRRetentionSiteDashboardController2.assignLeads - agent ' + agentUserWrapper.agent );
            System.debug('CFRRetentionSiteDashboardController2.assignLeads - agentUserWrapper ' + agentUserWrapper.numberOfLeadsToAssign );
          //  System.debug('CFRRetentionSiteDashboardController2.assignLeads - ListOfLead - ' + ListOfLead );

            for(Lead lead :leads) {
                    System.debug('CFRRetentionSiteDashboardController2.assignLeads - lead--' +lead);
                    lead.OwnerId = agentUserWrapper.agent.Id;
                    lead.Retention_Owner__c = agentUserWrapper.agent.Name;
                    if(currentSite != null) {
                        lead.Retention_Site__c = currentSite.Id;
                        leadsToUpdate.add(lead); 
                    }
              }                   
        }
        update leadsToUpdate;
        System.debug('CFRRetentionSiteDashboardController2.assignLeads-- leadsToUpdate'+leadsToUpdate); 
Hello,

I want to show child objects of products on quoteline item in vf. I have written controller I am getting list of all the quote line items on the quote Now I want list of all supplier pricess(Child of product) in the product of quote line item. how i can get that?

public class supplierPricesController
{  
    private final Quote quote1;
    Public List<Quote> quote{get;set;}
    string quoteid= ApexPages.currentPage().getParameters().get('id');
    public list<QuoteLineItem> quotelist{get;set;}
    
    public supplierPricesController(ApexPages.StandardController stdController)
    {
        this.quote1 = (Quote)stdController.getRecord();
    /*  String soql=  'SELECT Id, Name, Product__c, Supplier__c, Manufacturer__c, Product_Family__c,Concatenate_Name__c, Supplier_Price__c.Product__r.Id FROM Supplier_Price__c';
           quote = Database.Query(soql); */
        system.debug('quoteid before if'+quoteid);
         if(quoteid !=null )
             system.debug('quoteid after if'+quoteid);
  quotelist= [select id, Product2Id, Quantity,Discount, Subtotal, TotalPrice, UnitPrice from QuoteLineItem where quoteid=: quoteid];
        system.debug('quotelistquotelistquotelistquotelistquotelistquotelist'+quotelist);
    }  
    
}
Thanks,
Utz

Hi, 

I am not able to cover this class. Can anybody help me?

public class fileImport {
    public Blob fileBody;
    public String fileName;
    public String templateName;
    public String careProgram;
    public Date fileDate;
    public String importName;
}

Thanks!
 

I am not able to cover test class. I am getting error in assert statement. It return status = new.
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases1' + updateCases); this is also null.
Can anyone suggest how to cover this test class?


Class: 
public static final String Query_To_Word_Services = 'Word Services';
public static final String Query_Reason_Turnover = 'Turnover';
public static final String Priority_7_Internal = '7-Internal';
public static final String Status_Resolved = 'Resolved';
public static final String Job_WS_Production_Stage_Completed = 'Completed';
public static Id queryRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Query').getRecordTypeId();
        Set<Id> completedJobsIds = new Set<Id>();
        for (Job__c job : newJobs) {
            if (job.WS_Production_Stage__c == 'Completed') {
                completedJobsIds.add(job.id);
            }
        }
        System.debug('CaseAssignmentRuleHelper.resolveCases completedJobsIds' + JSON.serialize(completedJobsIds));

        List<Case> updateCases = [
                SELECT Id, Status
                FROM Case
                WHERE Job__c IN:completedJobsIds
                AND recordtypeId = :queryRecordTypeId
                AND Query_To__c = :Query_To_Word_Services
                AND Query_Reason__c = :Query_Reason_Turnover
                AND Priority = :Priority_7_Internal
                AND Status != :Status_Resolved
        ];
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases1' + updateCases);

        for (Case updateCase : updateCases) {
            updateCase.Status = Status_Resolved;
        }
        if (!updateCases.isEmpty()) {
            update updateCases;
        }
        System.debug('CaseAssignmentRuleHelper.resolveCases updateCases' + JSON.serialize(updateCases));
    }

Test Class: 
  //Create account
        Account testAccount = TestUtilities.CreateAccount('testAcc', false);
        Insert testAccount;

        //Create contact
        Contact testContact = TestUtilities.CreateContact('testCon', testAccount, true);

        //Create opportunity
        Opportunity testOpportunity = TestUtilities.CreateOpportunity(testAccount, 'testOpp', true);

        //Create project
        Project__c testProject = TestUtilities.CreateProject('testPrj', testAccount, testOpportunity, false);
        testProject.Project_Type__c = 'Live';
        testProject.Form_Type__c = '10-K';
        testProject.Filing_Date__c = datetime.now();
        testProject.Account__c = testAccount.ID;
        testProject.Opportunity__c = testOpportunity.ID;
        Insert testProject;

        //Create job
        Job__c testJob = new Job__c();
        testJob.Job_Status__c = 'In Progress';
        testJob.Account__c = testAccount.id;
        testJob.Project_Implementation__c = testProject.ID;
        testJob.WS_Production_Stage__c = 'Completed';
        insert testJob;
        System.debug('testJob---'+testJob);

       Id queryRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Query').getRecordTypeId();

        //Create case
        Case testCase = new Case();
        testCase.RecordTypeId = queryRecordTypeId;
        testCase.Query_To__c = 'Word Services';
        testCase.Query_Reason__c = 'Turnover';
        testCase.Priority = '7-Internal';
        testCase.Job__c = testJob.id;
        testCase.Status = 'New';
        Test.startTest();
        insert testCase;
        System.debug('testCase---: ' + testCase);
        update testJob;
        Test.stopTest();      
        
        Case testCase1 = [SELECT Status FROM Case WHERE Job__c =: testJob.id limit 1];
        System.debug('Status after trigger fired: ' + testCase1.Status);
        System.assertEquals(testCase1.Status, 'Resolved');
    }
Hello,
In my batch class execute method does not cover. Can anyone suggest me how to cover execute method.

/**
* Created by CS on 12-12-2018.
*/
public without sharing class opportunityTeamMemberBatch implements Database.Batchable<sObject>, Database.Stateful {
    public Map<Id, String> opportunitiesErrors;
    public Set<Id> processedOpportunityIds;
    public Integer totalSuccessRecords = 0;
    public Integer totalFailureRecords = 0;
    
    public opportunityTeamMemberBatch() {
        opportunitiesErrors = new Map<Id, String>();
        processedOpportunityIds = new Set<Id>();
    }
    
    public Database.QueryLocator start(Database.BatchableContext BC) {
        System.debug('opportunityTeamMemberBatch.start');
        
        String query = 'SELECT Id, TeamMemberRole, Opportunity.Opportunity_Team_Member_Aliases__c, OpportunityId '
            + ' FROM OpportunityTeamMember '
            + ' Where Opportunity.Opportunity_Team_Member_Aliases__c = null';
                System.debug('opportunityTeamMemberBatch.start query'+query);
        return Database.getQueryLocator(query);
    }
    
    public void execute(Database.BatchableContext BC, List<OpportunityTeamMember> opportunityTeamMembers) {
        System.debug('opportunityTeamMemberBatch.execute opportunityTeamMembers'+JSON.serialize(opportunityTeamMembers));
       
        Map<Id, OpportunityTeamMember > opportunityIdtoOpportunityTeamMembers = new Map<Id, OpportunityTeamMember>();
        for (OpportunityTeamMember opportunityTeamMember : opportunityTeamMembers) {
            opportunityTeamMember.TeamMemberRole = opportunityTeamMember.TeamMemberRole;
            opportunityIdtoOpportunityTeamMembers.put(opportunityTeamMember.OpportunityId, opportunityTeamMember);
        }
        
        if (opportunityIdtoOpportunityTeamMembers != null) {
            List<Database.SaveResult> opportunityTeamMemberResults = Database.update(opportunityIdtoOpportunityTeamMembers.values(), false);
            System.debug('opportunityTeamMemberBatch.execute opportunityTeamMemberResults:' + JSON.serialize(opportunityTeamMemberResults));
            Set<Id> processedOpportunityIds = new Set<Id>();
            Integer index = 0;
                for (Id opportunityId : opportunityIdtoOpportunityTeamMembers.keySet()) {
                    Database.SaveResult saveResult = opportunityTeamMemberResults[index++];
                    
                    if (saveResult.isSuccess()) {
                        processedOpportunityIds.add(opportunityId);
                        totalSuccessRecords++;
                        System.debug('Successfully updated opportunity IDs ' + processedOpportunityIds);
                    } else {
                        opportunitiesErrors.put(opportunityId, saveResult.getErrors()[0].getMessage());
                        System.debug('Error occurred' + opportunityId + ': ' + saveResult.getErrors()[0].getMessage());
                        totalFailureRecords++;
                    }
                    index++;
            }
        }
    }
    
    public void finish(Database.BatchableContext batchableContext) {
        System.debug('opportunityTeamMemberBatch.finish');

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        AsyncApexJob asyncApexJob = [
            Select asyncApexJob.TotalJobItems, asyncApexJob.Status, asyncApexJob.NumberOfErrors,
            asyncApexJob.JobType, asyncApexJob.JobItemsProcessed, asyncApexJob.ExtendedStatus, asyncApexJob.CreatedById,
            asyncApexJob.CompletedDate
            From AsyncApexJob asyncApexJob
            WHERE id = :batchableContext.getJobId()
        ];
        
        System.debug('opportunityTeamMemberBatch.finish Job id is' + batchableContext.getJobId());
        
        String[] toAddresses = new String[]{
            'utkarsha.up10@gmail.com'
                };
                    mail.setToAddresses(toAddresses);
        mail.setSubject('Batch Processing ' + asyncApexJob.Status);
        mail.setPlainTextBody('Total Success Records ' + totalSuccessRecords
                              + '\n Total Failure Records ' + totalFailureRecords
                              + '\n Total Batch Apex job processed:' + asyncApexJob.TotalJobItems
                              + '\n Job Item processed: ' + asyncApexJob.JobItemsProcessed
                              + '\n Failures: ' + opportunitiesErrors);
        Messaging.sendEmail(new Messaging.SingleEmailMessage []{
            mail
                });
        System.debug('opportunityTeamMemberBatch.finish mail sent successfully');
    }
}

Test class

/**
* Created by CS on 12-12-2018.
*/
@IsTest
private class opportunityTeamMemberBatchTest {
    
    @testSetup static void setup() {
        Profile profile = [SELECT Id FROM Profile WHERE Name = 'Standard User'];
        
        User user = new User();
        user.Alias = 'alias';
        user.ProfileId = profile.Id;
        user.Email = 'testMemberUser@dfsco.com';
        user.EmailEncodingKey = 'UTF-8';
        user.LanguageLocaleKey = 'en_US';
        user.LocaleSidKey = 'en_US';
        user.TimeZoneSidKey = 'America/Los_Angeles';
        user.UserName = 'testMemberUser@dfsco.com';
        user.LastName = 'testLastName';
        insert user;
        
        Account account = new Account();
        account.Name = 'Test Account';
        account.CIK__c = '1234567899';
        account.BillingStateCode = 'IL';
        account.BillingCountryCode = 'US';
        account.BillingCity = 'McLean';
        insert account;
        
        Opportunity opportunity = new Opportunity();
        opportunity.Name = 'Test Opportunity';
        opportunity.AccountId = account.Id;
        opportunity.StageName = 'Propose';
        opportunity.CloseDate = Date.today();
        opportunity.CurrencyIsoCode = 'USD';
        opportunity.LeadSource = 'Auditor';
        opportunity.Business_Line__c = 'Capital Markets';
        opportunity.Product_Type_Interests__c = 'AD Partner Product';
        insert opportunity;
        
        OpportunityTeamMember opportunityTeamMember = new OpportunityTeamMember();
        opportunityTeamMember.TeamMemberRole = 'AD Sales Team';
        opportunityTeamMember.UserId = user.Id;
        opportunityTeamMember.OpportunityId = opportunity.Id;
        insert opportunityTeamMember;
        System.debug('opportunityTeamMemberBatchTest opportunityTeamMember'+opportunityTeamMember); 
    }
    
    static testMethod void executeBatchApexTest() {
        Test.startTest();
        System.debug('executeBatchApexTest');
        opportunityTeamMemberBatch opportunityTeamMemberBatch = new opportunityTeamMemberBatch();
        Database.executeBatch(opportunityTeamMemberBatch);
        System.debug('executeBatchApexTest Database.executeBatch'+Database.executeBatch(opportunityTeamMemberBatch));
        Test.stopTest();
    }
    
    static testMethod void batchFinishMethod() {
    }
}
Hi,

I want to add custom link in lightning component instead of custom link or button.

Can any one tell how to add it in lightning component

Custom Link: https://dfsco--sync.lightning.force.com/lightning/r/Report/00O1b000000VDEfEAO/view?fv0={!Campaign.Id}

Thanks,
sfuser12
 
Hello,

I am using this code as I want same functionality- https://blogs.absyz.com/2018/07/12/custom-calendar-lightning-component/.

I did everything as mentioned. But I am getting error.
User-added image

I have copied code same as given in document. I didnt find any problem in handleclick function. ot getting what to do. Has anybody tried this before?

Thanks,
sfuser12
Hi,
I am writing test class which is 57% covered. But not getting how to cover    if (this.taskWhoId.getSobjectType() == Contact.SObjectType)

public String getNameWhoId() {
        if (String.isBlank(this.taskWhoId)) 
            return null;
        else
        if (this.taskWhoId.getSobjectType() == Contact.SObjectType)
            return [select name from Contact where id = :taskWhoId limit 1].name;
        else
            return null;
    }

Test Class:

 @TestSetup static void setup()
    {
        Account account = new Account();
        account.name='Test Account';
        account.Phone = '9872345617';
        account.Type = 'Prospect';
        account.BillingCity='Testcity';
        account.BillingStateCode='IL';
        account.BillingCountryCode='US';
        insert account;

        Contact contact = new Contact();
        contact.FirstName = 'firstName';
        contact.LastName = 'lastName';
        contact.Accountid= account.Id;
        contact.Email__c = 'xyz@testorg12.com';
        contact.MailingCity = 'Testcity';
        contact.MailingStateCode='IL';
        contact.MailingCountryCode='US';
        insert contact;

        Task task = new Task();
        task.Type = 'Email';
        task.Description = 'Test Description';
        task.OwnerId = UserInfo.getUserId();
        task.WhatId = account.Id;
        task.WhoId = contact.Id;
        task.Primary__c = 'Survey';
        task.Call_Topic__c = 'ActiveDisclosure';
        task.Status = 'New';
        task.Subject = 'Test Subject';
        task.Priority = 'Low';
        insert task;
    }

    @isTest static void testgetNameWhoId() {
        List<Task> tasks = [Select Id from task limit 1];
        CCSelfFilingTrainingController getIds = new CCSelfFilingTrainingController();
        getIds.getNameWhoId();
        getIds.getNameWhatId();

Can anyone tell me how to cover if condition in this case?
Hi All,

Can anyone please help me with bellow challenge.


Create an Apex trigger for Account that matches Shipping Address Postal Code with Billing Address Postal Code based on a custom field.
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.

For above challenge i tried with following code but looks like it doesnt mach the requirement.

trigger AccountAddressTrigger on Account (before insert, before update) {
    for(Account a : Trigger.new){
        If (a.Match_Billing_Address__c = true) {
            /*ShippingPostalCode = BillingPostalCode;*/
        }   
    } 

}

Please help me