+ Start a Discussion
Stavros McGillicuddyStavros McGillicuddy 

Code fires too fast

With a lot of help from the forum over the past week, I have a custom button that performs a series of functions on the Opportunity object

 1. It copies 6 fields to six custom fields
 2. It clears the 6 fields
 3. It copies all Opportunity Line Items to a Custom field
 4. It deletes all Opportunity Line Items

It seems like item 4 sometimes fires before 3 has completed so, the Opportunity line Items never make it into the custom field.

Realizing I'm a noob, is there an easy remedy? Maybe have a message box popup that fires the code for Item 4 on it?
Hugh Wheeler 46Hugh Wheeler 46
Are you using Apex/Visualforce, or a the apex toolkit on a javascript button by any chance?  I believe some calls in the Ajax toolkit are asynchronous.  Which means they could be executed out of sequence.