• David Budimir
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hey all,

I've been working with the below trigger. I've had no problem executing this in our current Sanbox enivorment (seemed to work fine), but I don't understand why theres no code coverge here at all. Does anything stand out as being obviously wrong? 

Thanks in advance,
David
trigger AccountAfter on Account (after insert, after update){
 
Set<Id> parentAccs = new Set<Id>{};
Map<Id, Integer> childCount = new Map<Id, Integer>{};
 
for (Account a : trigger.new)
if(a.ParentId != null)
parentAccs.add(a.ParentId);  //collect parent ids
 
for(Account acc : [Select Id, ParentId from Account where ParentId IN :parentAccs]){
if(childCount.get(acc.ParentId) == null)
childCount.put(acc.ParentId, 0);  //create a counter for parent
 
childCount.put(acc.ParentId, childCount.get(acc.ParentId) +1); //increment counter
 
}
 
List<Account> accsUpdate = new List<Account>{};
 
for(Id accId : childCount.keySet())
accsUpdate.add(new Account(Id = accId, ChildCount__c = childCount.get(accId))); //set parent counts
 
if(accsUpdate != null && !accsUpdate.isEmpty())
Database.update(accsUpdate); //update parent accounts
}

 
Hi all, hoping to get some help to solve this.  :)

We identfy deals that that have an opt out clause with a checkbox in opportunities. However we want to prevent our sales reps from offering a certain number of opt out deals in a certian period (ex. 2 per month).

Is there a way to create a validation rule that counts the number of open "opt out" opportunities (for a specific opportunity owner) that produces an error when they try to go beyond that threshold?

In other words - how can I have a rule that counts the number of times Opt-Out = True for a specific user. Thanks!
Hi there,

I'm trying to find a way to trigger a user look up field to populate automatically based on a picklist in a given opportunity. 

For example. We have a picklist for "Success Manager" where each individual is a  value. I'd like to get the value in this picklist to map to a specifc user lookup value in the same opportunity. 

That way we can start sending automatic email alerts to the Success Manager on that opportunity.

The main reason I want to set it up this way is so that our team doesn't have to change their current behaviour - and we can transtition to reccording the Success Managers the right way.

Thanks in advance!

Thanks!
Hi there,

Is there a way to create a formula field that can help me to identify the last user that changed a specific set of fileds in an opportunity? "Last Modified By" tells me about any changes made to an opportunity but I'd like to limit it to specific fields. 

For example - who was the last user to modify only the Ammount, Contract Start Date or Contract End Date Fields. How can the formula field identify the user that changed only a set list of fields. 

Thanks!
I'm trying to find a way to create a validation rule that is restricted by the the stage of the most recent opportunity.

In other words - if an account contains an opportunity that is open I'd like to prevent certain fields form being edited in that account. 

Conversley if an opportunity goes from open to closed won - I'd love to be able to update various account fields like account Type (from "Prospect to Customer").

Eager to hear your help. Thanks!


 
Hi all, hoping to get some help to solve this.  :)

We identfy deals that that have an opt out clause with a checkbox in opportunities. However we want to prevent our sales reps from offering a certain number of opt out deals in a certian period (ex. 2 per month).

Is there a way to create a validation rule that counts the number of open "opt out" opportunities (for a specific opportunity owner) that produces an error when they try to go beyond that threshold?

In other words - how can I have a rule that counts the number of times Opt-Out = True for a specific user. Thanks!
Hi there,

Is there a way to create a formula field that can help me to identify the last user that changed a specific set of fileds in an opportunity? "Last Modified By" tells me about any changes made to an opportunity but I'd like to limit it to specific fields. 

For example - who was the last user to modify only the Ammount, Contract Start Date or Contract End Date Fields. How can the formula field identify the user that changed only a set list of fields. 

Thanks!