You need to sign in to do that
Don't have an account?
sankum
how solvethis issue using trigger
hi to all ,
I have one object name 'product' and it has fields like avalable products, howmany products selected
my requirement is total products have 1000 if i selected 22 products , then available products is (1000 minus(-) 22)
how to write the code for this!!!
Please help...
Try like this
trigger PopulateAvailableproduct on Product__c(before insert,before update){
for(Product__c p: Trigger.new){
if(p.TotalProduct__c != NULL && p.howmanyproductsselected__c != NULL){
p.AvailableProduct__c = p.TotalProduct__c - p.howmanyproductsselected__c;
}
}
}
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
What you described sounds like a simple math rule that is active at all times, which should not require writing any code. It could be accomplished with a Workflow Rule + Field Update, or even a Formula Field.
Workflow Rule - every time a 'product' is edited
Do Field update: Available Products = 1000 - Selected products.
Or just make Available Products a formula field. Formula value = 1000 - Selected products (at all times).