You need to sign in to do that
Don't have an account?
swethasfdc
Locking syntax that prevents record update conflicts
Can anyone explain about the locking syntax in a trigger with an example that prevents record update conflicts???
Thank you,
swetha.
Hi,
You can create condition in trigger .if the condition will not meets your criteria then generate the error message.
For example refer the below code trigger on account to prevent the changing of the account name
trigger duplicateaccount on Account (Before upadate)
{
if(trigger.isupdate)
{
if(trigger.new[0].name!=trigger.old[0].name)
{
trigger.new[0].name.addError('you can not change the account name');
}
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
If I'm hearing you right - you're talking more about DBMS record update collisions (row locking, etc)?
Two approaches:
1) Standard SF interface - there is no record locking. If Jane views the details of a record and begins editing...and in the meantime Tom goes in and performs a quick inline update....Jane will get an error when she saves. There is no locking - first to update wins...the loser gets a "stale record" error.
2) Apex / Visualforce - you CAN lock a record if you're going the custom route. In your SOQL statement, you can designate the records being retrieved as LOCKED for update. As with any DBMS - use caution when you're choosing to lock records.
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_locking_statements.htm
SOQL Example:
Does that help?
-Andy