You need to sign in to do that
Don't have an account?
Jeff Bomar
Really new to Apex Trigger and Classes need to know the correct way
Any help would be much appreciated I feel like I am spinning my wheels here.
I have a custom object called Custom_Programming__c I have three fields on that object called Total_Hours__c and Custom_Type__c and Custom_Balance.
when a user updates or creates a Custom_Programming__c record and there is a value in Total_Hours__c I need a trigger.
what the trigger needs to do is query the DAKCS price book and get two unit prices one for 'Tape Drop' and one for 'Custom Development' I am using this query to grab the information
SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'
The trigger will only fire if hours get entered or changed in Custom_Programming__c.Total_Hours__c
The trigger looks at Custom_Programming__c.Custom_Type__c and calculates Custom_Programming__c.Custom_Balance.
if Custom_Programming__c.Custom_Type__c = 'Bug Fix' or 'No Billing' then Custom_Programming__c.Custom_Balance is always 0.00
If Custom_Programming__c.Custom_Type__c = 'Tape Drop' then Custom_Programming__c.Custom_Balance would be the UnitPrice of 'Tape Drop' + UnitPrice of ('Custom Development' * Custom_Programming__c.Total_Hours__c)
and everything else would be 'Custom Development' * Custom_Programming__c.Total_Hours__c
**Note**
values of the pricebook entries
'Tape Drop' = 750.00
'Custom Development' = 185.00
I have tried many different ways after watching many different videos so any help would be greatly appreciated.
I have a custom object called Custom_Programming__c I have three fields on that object called Total_Hours__c and Custom_Type__c and Custom_Balance.
when a user updates or creates a Custom_Programming__c record and there is a value in Total_Hours__c I need a trigger.
what the trigger needs to do is query the DAKCS price book and get two unit prices one for 'Tape Drop' and one for 'Custom Development' I am using this query to grab the information
SELECT UnitPrice FROM PricebookEntry WHERE Product2.Name IN('Custom Development','Tape Drop')AND PriceBook2.Name='DAKCS'
The trigger will only fire if hours get entered or changed in Custom_Programming__c.Total_Hours__c
The trigger looks at Custom_Programming__c.Custom_Type__c and calculates Custom_Programming__c.Custom_Balance.
if Custom_Programming__c.Custom_Type__c = 'Bug Fix' or 'No Billing' then Custom_Programming__c.Custom_Balance is always 0.00
If Custom_Programming__c.Custom_Type__c = 'Tape Drop' then Custom_Programming__c.Custom_Balance would be the UnitPrice of 'Tape Drop' + UnitPrice of ('Custom Development' * Custom_Programming__c.Total_Hours__c)
and everything else would be 'Custom Development' * Custom_Programming__c.Total_Hours__c
**Note**
values of the pricebook entries
'Tape Drop' = 750.00
'Custom Development' = 185.00
I have tried many different ways after watching many different videos so any help would be greatly appreciated.