You need to sign in to do that
Don't have an account?
mohi
Re: trigger update chkbox true on updating picklist value
hi i hve custom obj candidateinfo__c:
DemoCountri picklist
trigger testchkboxtrigger on CandidateInfo__c (after update)
{
for(CandidateInfo__c c:trigger.new)
{
if(c.DEmoCountry__c =='us')
{
c.Home__c = true;
}
}
update trigger.new;
}
plshelp trigger if fire exception
Please check the variable name "DemoCountri" and you have used "DEmoCountry__c".
If this is only writing mistake, then please provide exception detail.
Thanks,
Hemant
Hi mohi,
From your code, the trigger will fire recursivley. Because, it is a after Update trigger and in the code you have inculed "update trigger.new". This statement will again execute the update and then execute after update trigger again which will in turn.....and it goes till it hits governor limit. This might have caused an exception.
If I have understood your requirement correctly, you have to check a check box field named "Home" in case DEmoCountry is "us". For this, you need to use "before update event" and no need for "update trigger.new".
So your code would look like this
Before update trigger executes just before actual update happens and during this time if you happen to do any changes on fields those values will be considered for DML update. And here, the system will automatically perform update, once.
Hope this helps