Community
Showing results for 
Search instead for 
Do you mean 
Reply

Need HELP! Field changed event???

Copper Super Contributor
Posts: 71
Country: Canada

Need HELP! Field changed event???

Hello Everyone,

 

I want to be able to have a message box popup when a certain field in ACT! is changed, what is the coding for this, the field is called "Sales Person". So when the user types in a new value and either tabs off that field or clicks on a new field or whatever it pops up with a message box. Any ideas are greatly appreciated.

Employee
Posts: 1,163
Country: USA

Re: Need HELP! Field changed event???

What portion of the code are you looking for? Signing up for the field changed event for testing it once the event is fired for whether or not the field that changed was your field?

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Need HELP! Field changed event???

Basically I am looking for whatever portion allows me to run code when that one sepcific field is changed, not others.

Employee
Posts: 1,163
Country: USA

Re: Need HELP! Field changed event???

This is from a project I hadlaying around. I sign up for the field changed event within the contact changed event.

 

Contact c = ActApp.ApplicationState.CurrentContact;
c.Fields.FieldChanged += new MutableEntity.FieldCollection.FieldChangedHandler(Fields_FieldChanged);

 

The method that is created by monitoring this event has the fields name as a parameter, you could simply use it to test whether or not the field that has changed is the field that your concerend with.

 

void Fields_FieldChanged(string fieldName)
        {
           
            
        }

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Need HELP! Field changed event???

Just a few questions with your code, where do I type in what field I want to monitor to see when it has changed, and does the code you provided only run when the current contact is changed or as soon as you click off that field? Thanks.

Employee
Posts: 1,163
Country: USA

Re: Need HELP! Field changed event???

I'd use the parameter of the field changed event and create a conditional statement to determine if the field name that has changed is the field name of the field I care about, so:

 

void Fields_FieldChanged(string fieldName)
{
   if(fieldName == myFields)

    {
    }       
}

 

This event will fire once changes have been made to a field and you either leave the field, refresh or move to another contact.

 

It's worth noting here that currently the field changed event does not fire until after the first refresh.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Need HELP! Field changed event???

Hey Matthew,

 

So sorry to keep buggin you but I am not good at this, is that code for .cs or .vb. Could you show me how to change it to work in .vb, it needs a private or public sub correct? Also can you show me exactly how the code would look if I wanted it to run when a field called Sales Person was changed, and show me where I would put the code that runs when it is changed. Thanks so much!

Nickel Elite Contributor
Posts: 937
Country: USA

Re: Need HELP! Field changed event???

I don't mean to confuse this thread - but if you just want to popup a dialog when the field is changed here's a different option:

 

Go to the define fields view in ACT! and set a field changed trigger for this field then select program and point to an .exe that you'll need to create which will pop up the message box.

 

 

 

Employee
Posts: 1,163
Country: USA

Re: Need HELP! Field changed event???

[ Edited ]

This is in C#, I don't have any examples in VB because I don't use it. The trasnlations (other than the Act stuff) should be pretty straightforward, you could probably just plug it into a C# to VB translator.

 

The access modifier will depend on you're project and the scope you'll need for the sub.

 

In the example myFields is a string variable with the name of the field stored in it. There's no way I can know the exact name of your field as once it's committed to the db it's name is modified so Sales Person would be something like TBL_CONTACT.CUST_SALESPERSON_7823417892.

 

The code you want to run would go inside of the conditional statement inside of the field changed method.

 

#Edit: Allen's suggestion will no doubt be much easier to implement.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 71
Country: Canada

Re: Need HELP! Field changed event???

Where can I go to find the name of the field, since you said it changes to something crazy like TBL_CONTACT.CUST_SALESPERSON_7823417892.