function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ivan WinzerIvan Winzer 

rollup summary on custom object

Ok so I am still learning coding and with so many code examples i think im getting confused so hopefully someone can help lead me in the right direction.

So company is trying to do a rewards type program. So for every opprotunity the contact has that has a revenue center of 'ECOM' within a time frame will count towards getting a reward when they have reached $600 then $2000. Now i dont have any lookups from the contact to opprotunity which has me lost. And id like to have this data rolled into a custom object Direct_Rewards__c so we can track when people join the program, drop out , then join again (i know very crazy)

So breakdown:

Have object Opprotunity that has purchases made by our customers and they have a feild called Revenue_Center__c which should equal 'ECOM'

Have object Direct_Rewards__c that has a Master Detail relationship with Contact. This object keeps track of the Start_Date__c, End_Date__c, Contact__c (Master Detail), Rewards_Points_Accumulated__c (number), and Active_Rewards_Member__c (checkbox) to insure its an active record.

Now what im looking to accomplish is Customer goes online and joins the club which creates a record. Then make a purchase online for $200. The opprotunity is added to SF and if the revenue center = 'ECOM' then the active Direct_Rewards__c record should pull that $200 total into the Rewards_Points_Accumulated__c field. Then if they come back agian and purchase the system will add the new purchase of $150 to the Rewards_Points_Accumulated__c field which would then have a total of $350.

Then once they hit $600 we give a reward and again at $2000 (which is the max and no more purchases should be added). Then come Jan 1st i will clear out the Rewards_Points_Accumulated__c field and only purcahses from that date will count towards the reward record.

Im probably asking for a lot but i hope someone can help me. Im trying different codes but trying to get the data from the Opp to pull into the direct reward record based on a contact is where i get stuck.

Your help is majorly appreciated.

Ivan
Ivan WinzerIvan Winzer
Oh and just ot mention Opprotunities are linked to Accounts, and Contacts are linked to an Account so there is no connection between the contact and Opprotunity objects.