You need to sign in to do that
Don't have an account?
twrig15
How to calculate a field based on a picklist value
Hello,
I'm trying to calculate a field based on a specific picklist value. Not sure if I need a Apex trigger or a formula.
If a picklist value is changed to a specfic value and then count all the related list records custom hours field from that point.
Example: Pick Name: Type of Training, Value = Online
At this one whenever a record meets this criteria. All training hours created should be counted. But should only be counted when the above value is true.
I'm trying to calculate a field based on a specific picklist value. Not sure if I need a Apex trigger or a formula.
If a picklist value is changed to a specfic value and then count all the related list records custom hours field from that point.
Example: Pick Name: Type of Training, Value = Online
At this one whenever a record meets this criteria. All training hours created should be counted. But should only be counted when the above value is true.
All Answers
Yes we can achieve this using the Trigger. Please provide the Object and Field API Names along with an example so that it will be easy to help you.
Regards,
Mahesh
Mahesh,
Below is the validation rule created but only works after the record is created. Is as all the Object and API inform required.
Example:
Account__r.Total_Of_Hours_Purchased__C = 10
Account__r.Total_of_Hours_Used__c = 8
A rep goes to create a training for this customer for 3 hours. The rep should not be able to save the record because the training hours will exceed the 10 hours purchased.
- Account__r.Total_of_Hours_Used__c is a roll up summary field that sums up all the training hours from the Training related list on the Account.
This trigger would created on the Training Custom object (API Name:Training__c).
Current Validation Rule:
AND(Account__r.Total_of_Hours_Used__c > Account__r.Total_Of_Hours_Purchased__c, ISPICKVAL( Account__r.Training_Billing_Type__c, "Prepaid"),
AND( ISNEW()
)
)
Thank you!