• Tanushree Singh 11
  • NEWBIE
  • 25 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
We upgraded to the latest Amazon Connect CTI for Contact but we are facing issues with passing value for ActivityDate (Task) in the custom CTI Flow which we have built.

Please see attached picture for clarity.User-added imageCould anyone please help with fixing this?

Thanks in advance!
Tanushree
I have a trigger as follows:

trigger LeadConvert on Lead (after update) {

  // no bulk processing; will only run from the UI
  if (Trigger.new.size() == 1) {

    if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {

      // if a new account was created
      if (Trigger.new[0].ConvertedAccountId != null) {

        // update the converted account with some text from the lead
        Account a = [Select a.Id, a.Initial_Payment__c, a.BPS__c,a.Monthly_Payment__c, a.X401_k_Plan_Type__c From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
        if (a.X401_k_Plan_Type__c == 'Individual')
        {
            a.NumberOfEmployees = Integer.Valueof(Trigger.new[0].Number_of_Owners__c);
        }
        update a;

      }         

      }        

    }

  
}

It maps converted lead field to an account field.

Have written a test for the same which is giving 0% code coverage.

@isTest
private class LeadConvertTest {
@testSetup static void setup() {
        User users2=createUser();
        system.runAs(users2){
            Lead l1=new Lead();
            l1.LastName='test';
            l1.Number_of_Owners__c = 25;
            insert l1;
   
        }
    }
    
    @isTest
    static void updateAccount1(){
        user us2=[select Id from user where  Email ='xxx@ddd.com'];
        system.runAs(us2){
            Account a2=[select Id from Account limit 1];
            a2.X401_k_Plan_Type__c = 'Individual';
            update a2;
            
        }
        
    }
    
    
    private static user createUser(){
        User plannerUser2 = new User(
            ProfileId = [SELECT Id,name FROM Profile where name='System Administrator'].Id,
            LastName = 'last',
            Email = 'xxx@ddd.com',
            Username = 'xxx@ddd.com' + System.currentTimeMillis(),
            CompanyName = 'TEST1',
            Title = 'title',
            Alias = 'alias',
            TimeZoneSidKey = 'America/Los_Angeles',
            EmailEncodingKey = 'UTF-8',
            LanguageLocaleKey = 'en_US',
            LocaleSidKey = 'en_GB',
            IsActive=true);
        database.insert(plannerUser2);
        return plannerUser2;
    }
    
}

I am new to development and any help woulf be graetly appreciated.
Hi, I am new as a Developer and have just written a trigger. Could somebody please help me write test calsses for the same?

Here goes the Trigger:

trigger OpportunityUpdResigned on Account ( after update) {
    set<Id> setAccountId = new set<Id>();
    for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c )
        {
            if (a.Fund_Date__c == null ||a.Assets_Under_Management__c ==null){
            setAccountId.add(a.Id);
            }
        }
    }
    List<Opportunity> lstOpportunity = [SELECT Id, StageName FROM Opportunity WHERE AccountId IN: setAccountId];
    for(Opportunity objOpp: lstOpportunity)
    {
        if(objOpp.StageName == 'Closed Lost'){
                objOpp.StageName = 'Installed';
            objOpp.Closed_Lost_Reason__c = null;
        }
    }
    update lstOpportunity;
 
I have a trigger which is working absolutely fine. It tries to update an opportunity field (Stage) when the Resigned Date is changed and the Fund date is deleted. It is as below:

trigger OpportunityUpdResigned on Account ( after update) {
    set<Id> setAccountId = new set<Id>();
    for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c && a.Fund_Date__c == null)
        {
            setAccountId.add(a.Id);
        }
    }
    List<Opportunity> lstOpportunity = [SELECT Id, StageName FROM Opportunity WHERE AccountId IN: setAccountId];
    for(Opportunity objOpp: lstOpportunity)
    {
        if(objOpp.StageName == 'Closed Lost'){
                objOpp.StageName = 'Installed';
            objOpp.Closed_Lost_Reason__c = null;
        }
    }
    update lstOpportunity;
}

Now, there is  one more condition to be added. It is to check if the Assets Under Management field is also blank. So, when I am trying to change the if condition like this:

for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c && (a.Fund_Date__c == null ||a.Assets_Under_Management__c))
        {
            setAccountId.add(a.Id);
        }
    }

it's not helping to achieve the business result.
Our Sales Team wanted that the 'To' field on the Opportunity Email Activity tab to get auto-populated with the Contact email id. So, I created a custom activity tab and created a couple of other fields to achieve the functionality. Now, the 'To' field is getting populated automatically. But, now they want that the email address should appear as a name. This is beacuse there are several email templates that they are using which uses the merge fields from the 'To' field.

Could anybody help me in displaying an email adress as a name in the 'To' field?
I want to auto-populate the standard 'Lead Source' (picklist) field with a part of the string stored in another field called the Source Tracking Code. The Source Tracking Code looks something like this -- Offline>TradeShow>SHRM2018>>

For this I have created an Apex class to break the string into parts and then search for the part which matches the picklist values. Please note that I have created a custom picklist field Lead Source3 (using instead of Lead Source) for Testing


public class LeadSource {

public static void LeadSource(){
List<Lead> l = new List<Lead>();

for(Lead ls:l)
{
String alpha = ls.Manticore_Full_Promotion_Code__c;
List<String> lstAlpha = alpha.split('>');

Set<String> convertInSet = new Set<String>(lstAlpha);

String FinalValue;

if(convertInSet.contains('401k Exchange')){
    FinalValue = '401k Exchange';
}
else if(convertInSet.contains('Affiliate')){
    FinalValue = 'Affiliate';
}
else if(convertInSet.contains('Bing')){
    FinalValue = 'Bing';
}


ls.Lead_Source3__c = FinalValue;

}
 

}
}


After this I created a Trigger to run this Apex class as below

trigger LeadSource on Lead (before insert, before update) {


for(Lead myLeads:Trigger.new){

LeadSource.LeadSource();
}
}

I am new to Programming and to Salesforce, could somebody please help me figure out why I am not able to get anything populated on the Laed Source3 field.

Thanks,
Tanushree
 
I have a trigger as follows:

trigger LeadConvert on Lead (after update) {

  // no bulk processing; will only run from the UI
  if (Trigger.new.size() == 1) {

    if (Trigger.old[0].isConverted == false && Trigger.new[0].isConverted == true) {

      // if a new account was created
      if (Trigger.new[0].ConvertedAccountId != null) {

        // update the converted account with some text from the lead
        Account a = [Select a.Id, a.Initial_Payment__c, a.BPS__c,a.Monthly_Payment__c, a.X401_k_Plan_Type__c From Account a Where a.Id = :Trigger.new[0].ConvertedAccountId];
        if (a.X401_k_Plan_Type__c == 'Individual')
        {
            a.NumberOfEmployees = Integer.Valueof(Trigger.new[0].Number_of_Owners__c);
        }
        update a;

      }         

      }        

    }

  
}

It maps converted lead field to an account field.

Have written a test for the same which is giving 0% code coverage.

@isTest
private class LeadConvertTest {
@testSetup static void setup() {
        User users2=createUser();
        system.runAs(users2){
            Lead l1=new Lead();
            l1.LastName='test';
            l1.Number_of_Owners__c = 25;
            insert l1;
   
        }
    }
    
    @isTest
    static void updateAccount1(){
        user us2=[select Id from user where  Email ='xxx@ddd.com'];
        system.runAs(us2){
            Account a2=[select Id from Account limit 1];
            a2.X401_k_Plan_Type__c = 'Individual';
            update a2;
            
        }
        
    }
    
    
    private static user createUser(){
        User plannerUser2 = new User(
            ProfileId = [SELECT Id,name FROM Profile where name='System Administrator'].Id,
            LastName = 'last',
            Email = 'xxx@ddd.com',
            Username = 'xxx@ddd.com' + System.currentTimeMillis(),
            CompanyName = 'TEST1',
            Title = 'title',
            Alias = 'alias',
            TimeZoneSidKey = 'America/Los_Angeles',
            EmailEncodingKey = 'UTF-8',
            LanguageLocaleKey = 'en_US',
            LocaleSidKey = 'en_GB',
            IsActive=true);
        database.insert(plannerUser2);
        return plannerUser2;
    }
    
}

I am new to development and any help woulf be graetly appreciated.
Hi, I am new as a Developer and have just written a trigger. Could somebody please help me write test calsses for the same?

Here goes the Trigger:

trigger OpportunityUpdResigned on Account ( after update) {
    set<Id> setAccountId = new set<Id>();
    for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c )
        {
            if (a.Fund_Date__c == null ||a.Assets_Under_Management__c ==null){
            setAccountId.add(a.Id);
            }
        }
    }
    List<Opportunity> lstOpportunity = [SELECT Id, StageName FROM Opportunity WHERE AccountId IN: setAccountId];
    for(Opportunity objOpp: lstOpportunity)
    {
        if(objOpp.StageName == 'Closed Lost'){
                objOpp.StageName = 'Installed';
            objOpp.Closed_Lost_Reason__c = null;
        }
    }
    update lstOpportunity;
 
I have a trigger which is working absolutely fine. It tries to update an opportunity field (Stage) when the Resigned Date is changed and the Fund date is deleted. It is as below:

trigger OpportunityUpdResigned on Account ( after update) {
    set<Id> setAccountId = new set<Id>();
    for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c && a.Fund_Date__c == null)
        {
            setAccountId.add(a.Id);
        }
    }
    List<Opportunity> lstOpportunity = [SELECT Id, StageName FROM Opportunity WHERE AccountId IN: setAccountId];
    for(Opportunity objOpp: lstOpportunity)
    {
        if(objOpp.StageName == 'Closed Lost'){
                objOpp.StageName = 'Installed';
            objOpp.Closed_Lost_Reason__c = null;
        }
    }
    update lstOpportunity;
}

Now, there is  one more condition to be added. It is to check if the Assets Under Management field is also blank. So, when I am trying to change the if condition like this:

for(Account a : Trigger.new){
        if(a.Resigned_Date__c != trigger.oldMap.get(a.Id).Resigned_Date__c && (a.Fund_Date__c == null ||a.Assets_Under_Management__c))
        {
            setAccountId.add(a.Id);
        }
    }

it's not helping to achieve the business result.
I want to auto-populate the standard 'Lead Source' (picklist) field with a part of the string stored in another field called the Source Tracking Code. The Source Tracking Code looks something like this -- Offline>TradeShow>SHRM2018>>

For this I have created an Apex class to break the string into parts and then search for the part which matches the picklist values. Please note that I have created a custom picklist field Lead Source3 (using instead of Lead Source) for Testing


public class LeadSource {

public static void LeadSource(){
List<Lead> l = new List<Lead>();

for(Lead ls:l)
{
String alpha = ls.Manticore_Full_Promotion_Code__c;
List<String> lstAlpha = alpha.split('>');

Set<String> convertInSet = new Set<String>(lstAlpha);

String FinalValue;

if(convertInSet.contains('401k Exchange')){
    FinalValue = '401k Exchange';
}
else if(convertInSet.contains('Affiliate')){
    FinalValue = 'Affiliate';
}
else if(convertInSet.contains('Bing')){
    FinalValue = 'Bing';
}


ls.Lead_Source3__c = FinalValue;

}
 

}
}


After this I created a Trigger to run this Apex class as below

trigger LeadSource on Lead (before insert, before update) {


for(Lead myLeads:Trigger.new){

LeadSource.LeadSource();
}
}

I am new to Programming and to Salesforce, could somebody please help me figure out why I am not able to get anything populated on the Laed Source3 field.

Thanks,
Tanushree