You need to sign in to do that
Don't have an account?
rajesh k 10
when checkbox will be check how to update a field using trigger in salesforce?
Create a custom field cancel__c(checkbox) on sales_Order__c custom object.
Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 50%.
Whenever this checkbox gets checked, a trigger should fire and update the Discount percentage field to 50%.
the code looks fine to me.
Do you see anything in the debug log? Lets remove the onchange event.
try the code below
All Answers
You can check the value change in trigger by using code below
I got Foreignkey relationship error.
please help me..
I wrote like this but not working
trigger Trg_Discountupdateonorder1 on sales_Order__c(before update){
List<sales_Order__c> lst=new List<sales_Order__c>();
for(Sales_order__c so : trigger.new)
{
if(so.Cancel__c == true)
{
so.Discount__C =70;
lst.add(so);
}
}
if(lst.size() > 0)
{
update lst;
}
}
please help me..
Here where your checking cancel__c check is true or false.
Hi i tried but Discount field not updated and There is no debug log also
please help me..........
I try to like this but not working
trigger salesordertrigger on Sales_Order__c(before update){
for(Sales_order__c so : trigger.new){
if(so.Cancel__c && !trigger.oldmap.get(so.id).cancel__c )
{
if(so.Cancel__c == true)
{
so.discount__c=70;
}
}
}
}
the code looks fine to me.
Do you see anything in the debug log? Lets remove the onchange event.
try the code below