06-10-2008 11:33 PM
My plugin uses the 'ShowContact' method of UIContactManager
If you call this when there are pending changes to the currently displayed record, those changes are lost
To prevent this, I have been using actapp.ApplicationState.CurrentContact and checking the HasChanges member
I dont understand why but this is unreliable - if I make a change in a field and then click away to another field it is OK, but if I make a change and havent yet clicked away the 'HasChanges' is false.
Is there any sure-fire way of either getting an accurate 'HasChanges', either that or something I can do before 'ShowContact' that saves the pending changes - if you click on 'next contact' in the GUI it automatically saves the change.
This is in Act! 10 that I am experiencing this specifically - I dont have a previous version to compare against at this time.
06-11-2008 07:36 AM
What's probably happening is that HasChanges property is not modified until the control where the changes has made has lost focus. I think that's consistent behavior for forms not just in ACT!, but through out the dotNet world when it comes to Databound Forms. It's likely you will not be able to see changes in the HasChanges, without change the focus of the controls in the UI.
Anybody know this for certain?
Also as an alternative you could keep the current record's data cached when you first enter the record, and then check each control for data changes before you call ShowContact.
06-11-2008 08:40 AM
Mark its probably easiest just to call Actapp.ApplicationState.CurrentContact.Update - this will save the contact before you display the next one. The overhead on saving one contact isn't much so its easier to do this rather that check for changes.
06-11-2008 04:44 PM
Thanks guys for the suggestions, but unfortunately the Update() doesnt help - which makes sense I suppose - if Act! doesnt think the form is 'dirty' then it won't save it either
This is linked to my computer telephony application - I have a plugin in Act! that links to my CTI app for screen pops etc - for now I think I am going to have to make the screen pop manually selected rather than automatic - or at least make it optional - from what I can tell this isnt likely to be something that will go away
06-12-2008 03:04 PM
that sounds like a good plan - how do I programmatically move to the next field.
I tried a few days ago just using SendKeys with a \t, and also with a ^s just in case
06-13-2008 10:26 AM
I've not actually attempted to do that with .NET, or the ACT! SDK. If you can't get SendKeys to work, you could either attept to set focus on another control on the form, or add a space and remove it in the data for another field that you're not currently editing. This should trigger the change in the HasChanges property.
06-16-2008 06:18 PM
Havent got around to it as yet - but I am sceptical - I suspect that even though this will set the 'HasChanges' I doubt it will set the field I am editing in the GUI as changed
It would of course be neat if Act! warned you or just saved the changes - after all it knows when you click on 'next record' that it needs to save the changes - I will let you know once I have had an opportunity to try it anyway