2

I'm trying to access OpportunityLineItem whenever the SortOrder is changed. However the trigger for update actions doesn't fire when I hit the save button from the page where we sort the Opportunity products. Has someone else faced this problem? Who has a solution?

Thanks

Pedro Ribeiro

1

There are several elements in salesforce.com that do not fire triggers; I now know of two of them. Normally this doesn't matter, since sorting the records isn't really an "edit" in the usual sense, but if you're depending on the trigger firing, you'll have a problem. Since SortOrder is also read-only via Apex Code (without a clever hack), you're better off ignoring it. Another situation where this occurs is the "activate"/"deactivate" links on the product list view; changing the active status won't fire any triggers. There are at least two viable workarounds. The first involves a scheduled Apex Class that scans the system for changes to the sort order (updated by a trigger into a custom field), and then performs an action based on those changes, while the second involves creating a Visualforce page, overriding the default sort page, and then simulating the sort via the sorting hack and firing the triggers with a normal DML operation afterwards. Either method is messy and prone to breaking if this functionality changes (which hasn't happened as of yet, thankfully).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.