Community
Showing results for 
Search instead for 
Do you mean 
Reply

How to make ACT! wait while my code runs

Copper Contributor
Posts: 87
Country: USA

How to make ACT! wait while my code runs

I've used a BeginInvoke to allow an ACT! process to finish before my plugin code starts up, to handle situations like LayoutChanged or ContactChanged, when I want to work with the NEW object rather than the old.

 

How can I ask ACT! to wait for my plugin code to to finish before ACT! starts up, to handle situations like ContactChanging, when I want to work only with the OLD object rather than the new?

 

I have a plugin that is triggered by a ContactChanging event, but any new value entered into a field without moving the cursor before changing to a new contact causes that value to entered into boths contacts - the one being left and the one being entered. 

 

I'm doing a contact.update and a currentview.save at the beginning of my code, so that when I reference the field values for my process, I'm sure to get any new values entered by the user.  It appears that no matter what field is changed without moving the cursor, whether its a field that I reference or not, will be updated in both records.  But if I take out the contact.update or the currentview.save, then my process ends up using the old value of the changed field. 

 

I also do a contact.update at the end of my process, to force the commit after the contactfield.update statement, and of course, if I remove that, then the values that my process stores are not saved.

 

So how can I get ACT! to save the newly entered values, run my process, save and commit my changes, then continue on to the next record, without updating THAT record as well?

 

TIA,

Geoff

Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: How to make ACT! wait while my code runs

Goeff,

Why not use the contols validate event?
That way you are sure the user entered data would be updated.

 

-- jim durkin

Copper Contributor
Posts: 87
Country: USA

Re: How to make ACT! wait while my code runs

Jim,

I've suggested that, and allow the user to select field enter, valdiate and exit events.  But they chose, in this case, to use the Leaving Contact event instead.

 

Any other ideas?

Geoff

Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: How to make ACT! wait while my code runs

The controls validating and validated event will fire before the contactchange event.

 

I'm not sure what you mean by "But they choose...."

 

-- jim

Copper Contributor
Posts: 87
Country: USA

Re: How to make ACT! wait while my code runs

This is an application where the user defines their own trigger, selecting any of a number of events to be the one to fire the trigger.  Field change, entry and exit are 3 of their choices along with changing to a different contact, company or group as 3 more.  They could alsel select a menu item or toolbr icon.  Many of my enhancement products are like this, where the user defines their trigger, and the command to be executed when the trigger fires.  Therefore, the technique to be used here will have an impact on many different situations, and many different scenarios when the user decides that they want something to happen to the record being left, when they change to a new record.

 

The ContactChange event "fires" whenever any field on that contact record changes, correct?  Do you have any idea exactly what that means, "field changes"?  Is is every time a key is pressed while the cursor is in a control?  Only when the cursor leaves a control, having a different value than when the cursor entered?  Only when the contents of all the fields are "flushed" to the database?  Something else?

 

Geoff

Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994