• LStraub
  • NEWBIE
  • 25 Points
  • Member since 2009

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

I needed a way to count the number of Contacts on an Account that have ScarbBooklet check box marked. I could not use a Roll-up summary but I did find some Apex code that I modified and it works in my Sandbox.

 

However I am not a developer and dont know how to right code at all, so I have been looking at sample test classes but I can not find one I can decypher enough to modify to as a test for my particular trigger.  

 

I was wondering if any of you devs have a few minutes to look at my trigger and point me to a bit of test code that would be very obvious that i could modify?   Thanks in advance for any help!  --Laura

 

 

/* Provide summary of Number of Scarb Booklet Contacts on Account record */ trigger ContactSumTrigger on Contact (after delete, after insert, after undelete, after update) { Contact[] cons; if (Trigger.isDelete) cons = Trigger.old; else cons = Trigger.new; // get list of accounts Set<ID> acctIds = new Set<ID>(); for (Contact con : cons) { acctIds.add(con.AccountId); } Map<ID, Contact> contactsForAccounts = new Map<ID, Contact>([select Id,AccountId from Contact where AccountId in :acctIds and Scarborough_Booklet__c=True]); Map<ID, Account> acctsToUpdate = new Map<ID, Account>([select Id,Num_of_Scarb_Booklet_Contacts__c from Account where Id in :acctIds]); for (Account acct : acctsToUpdate.values()) { Set<ID> conIds = new Set<ID>(); for (Contact con : contactsForAccounts.values()) { if (con.AccountId == acct.Id) conIds.add(con.Id); } if (acct.Num_of_Scarb_Booklet_Contacts__c != conIds.size()) acct.Num_of_Scarb_Booklet_Contacts__c = conIds.size(); } update acctsToUpdate.values(); }

 

 

 

Basicallly some kind of workflow or control that says if this check box is checked then make sure the address for this contact always matches the Account Billing addresss or whatever?

Looking for help with a validation rule that makes sure the Close Date on an opportunity where the stage is any value 1 thru 9 is within the current month or a future month.  I have the following rule with works but, it breaks when we get to January of the next year. 

 

(MONTH(CloseDate) < MONTH(Today())) &&
(
(ISPICKVAL( StageName ,"1" )) ||
(ISPICKVAL( StageName ,"2" )) ||
(ISPICKVAL( StageName ,"3" )) ||
(ISPICKVAL( StageName ,"4" )) ||
(ISPICKVAL( StageName ,"5" )) ||
(ISPICKVAL( StageName ,"6" )) ||
(ISPICKVAL( StageName ,"7" )) ||
(ISPICKVAL( StageName ,"8" )) ||
(ISPICKVAL( StageName ,"9" ))
)

 

 

 I almost need 3 tests. 

1 - if YEAR(CloseDate) < YEAR(TODAY()) then check for StageName 1-9

2 - If YEAR(CloseDate) > YEAR (TODAY()) then skip test, no error 

3 - If YEAR(CloseDate) = YEAR(Today()) then run test on month and StageName. 

 

It seems totally doable but i can not figure it out and its making me crazy.  :)   Thanks for any help. 

--Laura

 

Message Edited by LStraub on 05-19-2009 12:06 PM

Hello

 

I'm a very new in all the salesforce business

i'm trying to make a new button in the account that will open me a new task with some data in the fields

 

 

Someone can help me ?

 

Thanks

Elad

 

 

  • September 08, 2009
  • Like
  • 0

Looking for help with a validation rule that makes sure the Close Date on an opportunity where the stage is any value 1 thru 9 is within the current month or a future month.  I have the following rule with works but, it breaks when we get to January of the next year. 

 

(MONTH(CloseDate) < MONTH(Today())) &&
(
(ISPICKVAL( StageName ,"1" )) ||
(ISPICKVAL( StageName ,"2" )) ||
(ISPICKVAL( StageName ,"3" )) ||
(ISPICKVAL( StageName ,"4" )) ||
(ISPICKVAL( StageName ,"5" )) ||
(ISPICKVAL( StageName ,"6" )) ||
(ISPICKVAL( StageName ,"7" )) ||
(ISPICKVAL( StageName ,"8" )) ||
(ISPICKVAL( StageName ,"9" ))
)

 

 

 I almost need 3 tests. 

1 - if YEAR(CloseDate) < YEAR(TODAY()) then check for StageName 1-9

2 - If YEAR(CloseDate) > YEAR (TODAY()) then skip test, no error 

3 - If YEAR(CloseDate) = YEAR(Today()) then run test on month and StageName. 

 

It seems totally doable but i can not figure it out and its making me crazy.  :)   Thanks for any help. 

--Laura

 

Message Edited by LStraub on 05-19-2009 12:06 PM

I'm trying to create a formula field that returns the value true or a numeric value of 1 (either value would work) where a custom field that is a date/time datatype is greater than the current month

 

I was trying the following, but it is not correct:

 

After Month End (TEXT) = IF(End__c > THIS MONTH, 'true', 'false')

 

I just want to check if the date in the custom field end__c is past the current month and if so, set the value to true or 1.

 

Thanks.