• Dave_Keller
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies

In order to show the date of the next activity on opportunities I need code for a trigger that finds the date and subject of the next open task/event of the opportunity and update custom opp fields Next_Activity_Date__c and Next_Activity_Subject__c.  I've been trying things based on what I've found searching the boards, but they did not work. Can anyone show the code needed?

I have made some custom activity fields successfully, but I need help making new ones that have ActivityDate in them. I do not see Date, ActivityDate, or ActivityDateTime in the Insert Field choices. My attempts to write it myself result in syntax errors.

 

Examples of objective that won't work for me now that I need help with (in the Activity Object):

 

1. Basic: New label: just "ActivityDate" with new field name

2. Show missed activities: IF(AND(ActivityDate < TODAY(),Closed = FALSE), "Past Due", "Future")

3. Days to next activity: IF(Closed = FALSE, ActivityDate - TODAY(), NULL)

 

How can I modify the above to realize them using a custom activity field?

I'm trying to get totals of opportunity amounts using "this week", "last week", "n weeks ago" in new custom fields, and then roll up the totals in summary reports. However, I get errors saying these don't exist, either with the underscore or without. How can I use them in calculated fields?

 

A typical use case would be:

 

IF(CloseDate = Last_Week,Amount,0)    or  IF(CloseDate = 3 weeks ago,Amount,0)

 

For me, TODAY() and Now() work, but not other literals. 

 

Guidance, please...

Needing to show some sums of custom field values from opportunities on Account pages, I have used the standard methods with often worked fine. However, some of my custom fields are available, and some are not, and I can't see what is different about them. 

 

Specifically I have a set of calculated fields that show the InForce policy value on quarter end dates. They work fine in opportunities. When I go to Account fields to roll them up, they aren't visible. When I try to roll up similar fields with year totals that have similar calculations, they are there. What is the secret?

In order to show the date of the next activity on opportunities I need code for a trigger that finds the date and subject of the next open task/event of the opportunity and update custom opp fields Next_Activity_Date__c and Next_Activity_Subject__c.  I've been trying things based on what I've found searching the boards, but they did not work. Can anyone show the code needed?

Needing to show some sums of custom field values from opportunities on Account pages, I have used the standard methods with often worked fine. However, some of my custom fields are available, and some are not, and I can't see what is different about them. 

 

Specifically I have a set of calculated fields that show the InForce policy value on quarter end dates. They work fine in opportunities. When I go to Account fields to roll them up, they aren't visible. When I try to roll up similar fields with year totals that have similar calculations, they are there. What is the secret?

Hi there.

 

I have a trigger that works almost perfectly but I need to change the behavior and I'm at a loss how to.

 

Behavior

Updates Opportunity field "Next Task Date" with the task due date

Updates Opportunity field "Next Task Subject" with the task subject

Triggered when

A new task is created or an existing open task is updated

ex. if there are 2 tasks , one due 1/1/2013 and another due 1/1/2014

if either one of these is updated or a new task is created, the opportunity fields are updated

Challenge

I need to limit the update so that it only pulls info from the next closest task due date

 

How do I change the trigger so that it achieves this? I would really appreciate some coding help.

 

Thanks  in advance. Please see code below.

 

trigger NextTaskInfo on Task (after insert, after update) {
//this is the trigger that updates next step and next step date on opportunity
  if(Trigger.new.size() == 1 ) {
    Task tk = Trigger.new.get(0);
      if (tk.WhatId != null && String.valueOf(tk.WhatId).startsWith('006')) { 
        Opportunity opp = [select OwnerId,NextTaskSubject__c,Next_Task_Date__c from Opportunity where Id = :tk.WhatId ];
          if( tk.OwnerId == opp.OwnerId && tk.ActivityDate != null) {                   
            if (tk.isClosed == false) {
              opp.Next_Step_Date__c = tk.ActivityDate;
              opp.NextStep = tk.Type;
              update opp;
}
}
}
}
}

 

 

  • December 31, 2011
  • Like
  • 0