• Jkk
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 3
    Replies
How to update an account field with value='abc' if any one of the corresponding opportunities have custom field test__c='xyz' via trigger?
  • October 26, 2019
  • Like
  • 0
I have a VF page which creates a new note (related list on event)when we click ' new note' custom button. once the records is created it redirects it back to event page showing certain fields of content note.I want to develop same functionality as mobile(lightning) compatible.Kindly suggest how to proceed.
  • July 02, 2019
  • Like
  • 0
Please help me with a trigger to populate latest contact record's email id on account field
  • May 24, 2019
  • Like
  • 0
I am trying to populate Notes_Preview__c on Description for event.
However it is not populating.

trigger:

if(trigger.isAfter ){
            if(trigger.isInsert || trigger.isUpdate ){
            EventTriggerUtil.updateDescription(trigger.new);
            }

class:
private static boolean Hassent = false;
    public void updateDescription(List<Event> eventList){
        List<Event> eventtoupdate = new List<Event>();
        If(!HasSent){
        for(event e:eventList){
            Event eve =new Event(Id = e.Id);
            eve.Description=eve.Notes_Preview__c;
            eventtoupdate.add(eve);
            HasSent=true;
        }
        }
        if(eventtoupdate.size()>0){
            update eventtoupdate;
        }
    
        
    }
  • April 19, 2019
  • Like
  • 0
trigger countmeetings on Event (after insert, after delete) {
List<id> levent = new List<id>();
Set<id> accid = new Set<id>();
List<Event> eventtoupdate = new List<Event>();
public integer inp=0;
if(trigger.isInsert){
for(Event ce:trigger.new){
accid.add(ce.WhatId);
}
}
if(trigger.IsDelete){
for(Event ce: trigger.old){
accid.add(ce.WhatId);
}
}
for(Event ev:[SELECT id FROM event WHERE whatid=:accid]){
    levent.add(ev.id);
}
for(Event event :[SELECT id,Distribution_Meetings__c FROM Event WHERE id=:levent]){
    event.Distribution_Meetings__c = levent.size();
    eventtoupdate.add(event);
    }
If(eventtoupdate.size()>0){
    update eventtoupdate;
}
    }
  • April 11, 2019
  • Like
  • 0
I am trying to cover the positive scenario of a class but i am receiving assetion fail error. Kindly help

Class:
 public class CTICallInitiationService {
 public static Id createServiceSessionRecord(String route, String callFrom, String customerType, String language, String branchPhone, String highestAuth, String trustedPhone){
        Service_Session__c serviceSessionRecord = new Service_Session__c(); 
        //serviceSessionRecord.Account_ID__c = accountId;
        serviceSessionRecord.Session_Type__c = 'Phone';        
        serviceSessionRecord.Highest_Authentication_Level_Achieved__c = highestAuth;       
        serviceSessionRecord.Authentication_Level__c = highestAuth;
        //serviceSessionRecord.Parent_Case__c=idCase;
        serviceSessionRecord.Created_Date_Time__c = System.now();
        serviceSessionRecord.Status__c = 'Active';
        serviceSessionRecord.Initiating_User__c = UserInfo.getUserId();
        serviceSessionRecord.Call_Route__c = route;
        serviceSessionRecord.Call_From_ANI__c = callFrom;
        serviceSessionRecord.Customer_type__c = customerType;
        serviceSessionRecord.Language__c = language;
        serviceSessionRecord.Branch_Phone__c = branchPhone;
        serviceSessionRecord.trusted_phone__c = trustedPhone;
        try {
            insert serviceSessionRecord;
        } catch(DmlException e) {
            serviceSessionRecord.id = null;
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
        return serviceSessionRecord.id;
        }
        }
    
Test Class:

@isTest(seeAllData=false)

private class CtiCallInitiationServiceTest {

    
     @isTest
    private static void ServiceSessionRecordTest(){
        /* Positive insertion */
        Id idSession1 = CtiCallInitiationService.createServiceSessionRecord('route', 'callFrom' , 'customerType' , 'language' , 'branchPhone' , 'highestAuth' , 'trustedPhone');
           /* Negative insertion */      
        Id idSession2 = CtiCallInitiationService.createServiceSessionRecord('test', '9080942889' , 'Consumer' , 'Test' , '9080942889' , 'Full' , 'Yes');
        
        Test.startTest(); 
        system.assertEquals(False, String.isBlank(idSession1));
           system.assertEquals(true, String.isBlank(idSession2));
        Test.stopTest();
    }
    
}
  • March 18, 2019
  • Like
  • 0
i am trying to create one to  one relation between campaign and campaign member like one campaign member for one campaign.
below is  my code:
trigger CampaignmemberControl on CampaignMember (before insert) {
    If(trigger.isInsert && trigger.isbefore){
        Set<String> CampaignMember_parentid=new Set<String>();
        for (CampaignMember cc:trigger.new){
            If(cc.Email !=null){
                CampaignMember_parentid.add(cc.CampaignId);
            }
            List <CampaignMember> listCampaign= [SELECT Id, Name,(SELECT Id FROM CampaignMembers) FROM Campaign WHERE Id IN:CampaignMember_parentid];
            for(CampaignMember cnew:trigger.new){
                if(listCampaign.size()>0)
                {
                    cnew.addError('Not Allowed');
                }
                
            }update listCampaign;
        }
    }

}

However i am facing error:  Illegal assignment from List<Campaign> to List<CampaignMember>

Please help me with this
  • August 09, 2018
  • Like
  • 0
I have a VF page which creates a new note (related list on event)when we click ' new note' custom button. once the records is created it redirects it back to event page showing certain fields of content note.I want to develop same functionality as mobile(lightning) compatible.Kindly suggest how to proceed.
  • July 02, 2019
  • Like
  • 0
Please help me with a trigger to populate latest contact record's email id on account field
  • May 24, 2019
  • Like
  • 0
I am trying to cover the positive scenario of a class but i am receiving assetion fail error. Kindly help

Class:
 public class CTICallInitiationService {
 public static Id createServiceSessionRecord(String route, String callFrom, String customerType, String language, String branchPhone, String highestAuth, String trustedPhone){
        Service_Session__c serviceSessionRecord = new Service_Session__c(); 
        //serviceSessionRecord.Account_ID__c = accountId;
        serviceSessionRecord.Session_Type__c = 'Phone';        
        serviceSessionRecord.Highest_Authentication_Level_Achieved__c = highestAuth;       
        serviceSessionRecord.Authentication_Level__c = highestAuth;
        //serviceSessionRecord.Parent_Case__c=idCase;
        serviceSessionRecord.Created_Date_Time__c = System.now();
        serviceSessionRecord.Status__c = 'Active';
        serviceSessionRecord.Initiating_User__c = UserInfo.getUserId();
        serviceSessionRecord.Call_Route__c = route;
        serviceSessionRecord.Call_From_ANI__c = callFrom;
        serviceSessionRecord.Customer_type__c = customerType;
        serviceSessionRecord.Language__c = language;
        serviceSessionRecord.Branch_Phone__c = branchPhone;
        serviceSessionRecord.trusted_phone__c = trustedPhone;
        try {
            insert serviceSessionRecord;
        } catch(DmlException e) {
            serviceSessionRecord.id = null;
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
        return serviceSessionRecord.id;
        }
        }
    
Test Class:

@isTest(seeAllData=false)

private class CtiCallInitiationServiceTest {

    
     @isTest
    private static void ServiceSessionRecordTest(){
        /* Positive insertion */
        Id idSession1 = CtiCallInitiationService.createServiceSessionRecord('route', 'callFrom' , 'customerType' , 'language' , 'branchPhone' , 'highestAuth' , 'trustedPhone');
           /* Negative insertion */      
        Id idSession2 = CtiCallInitiationService.createServiceSessionRecord('test', '9080942889' , 'Consumer' , 'Test' , '9080942889' , 'Full' , 'Yes');
        
        Test.startTest(); 
        system.assertEquals(False, String.isBlank(idSession1));
           system.assertEquals(true, String.isBlank(idSession2));
        Test.stopTest();
    }
    
}
  • March 18, 2019
  • Like
  • 0