• Preeti Shetty
  • NEWBIE
  • 35 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 6
    Replies
I need to copy a field to the Task Object from its related contact.The Contact field "Activity Conversion Days" is a number field which gets updated based on a workflow rule. I want to copy dat field to task. I have created a number field in thr Task object with the same name. I tried creating a Process but I am getting errors. Can someone please help me with this. Also this is the first time I am using Process Builder and Flows. I am attaching a screenshot of the Process and Flow I have created.

User-added imageUser-added imageUser-added imageUser-added image
Hi All,

In contacts I have two custom text fields called Secondary Source and opportunity Source. When I add the contact to a campaign I want the secondary source to be populated to the name of the campaign and Opportunity Source to be populated to the field campaign type (which is picklist field). Everytime I add the contact to a new campaign the source field should get updated. Is this possible??
Hi All ,

I am getting the following error while deploying a trigger
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ActivityTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Class.ActivityTriggerHandler.getContactIds: line 17, column 1 Class.ActivityTriggerHandler.updateCallCount: line 7, column 1 Trigger.ActivityTrigger: line 3, column 1: []
Stack Trace: Class.TestUpdateAccountEngScore.myUnitTest: line 61, column 1

This my trigger handler -
public class ActivityTriggerHandler {
    private final String SUB_CATEGORY_CALL = 'Call';
    private final String SUB_CATEGORY_UPDATE = 'Update';
    private final String CONTACT_API = 'Contact';
    
    public void updateCallCount(List<Task> taskList) {
        Set<Id> contactIdSet = getContactIds(taskList);
        List<Contact> contactList = [SELECT Call_Count__c FROM Contact WHERE Id IN :contactIdSet];
        updateContacts(contactList);
    }
    
    private Set<Id> getContactIds(List<Task> taskList) {
        Set<Id> contactIdSet = new Set<Id>();
        for(Task t : taskList) {
            if(t.Sub_Category__c == SUB_CATEGORY_CALL | t.Sub_Category__c == SUB_CATEGORY_UPDATE) {
                Id whoId = t.WhoId;
                if(whoId.getSObjectType().getDescribe().getName() == CONTACT_API)
                    contactIdSet.add(whoId);
            }
        }
        return contactIdSet;
    }
    
    private void updateContacts(List<Contact> contactList) {
        for(Contact con : contactList) {
            if(con.Call_Count__c == NULL || con.Call_Count__c == 0)
                con.Call_Count__c = 1;
            else if(con.Call_Count__c >= 1)
                con.Call_Count__c = con.Call_Count__c + 1;
        }
        update contactList;
    }
}
and this is my trigger
trigger ActivityTrigger on Task (after insert, after update) {
    ActivityTriggerHandler handler = new ActivityTriggerHandler();
    handler.updateCallCount(Trigger.New);
}
Please help me resolve this.


 
I have a field called "Call_Count__c" which is a number field in Contact. I want that when some one logs a call and if the Subject Category is "Call" or "Update" the Call Count field should increase by 1. for eg if value in call count field is 3 it should become 1. Please help me with a trigger for this.