Community
Showing results for 
Search instead for 
Do you mean 
Reply

Influencing the Sage Act application from the outside.

Copper Contributor
Posts: 150
Country: Belgium

Influencing the Sage Act application from the outside.

Hello,

 

I'm wondering if it's possible to write an application using the SDK that can influence the Act application from the outside. So not a plug-in residing in Act but a separate app.

 

We have an app that reads and shows history items in a grid which are intended for the user. So basically these history items contain a unique code for that user. Right now when the user right clicks the history item it shows a menu "Go to act record" this triggers a small autohotkey script that, if act is open, brings it to the front and does a lookup of the company (simulates the keypresses alt+l -> alt+n, types contact name and presses enter).

 

This however is horribly inefficient and is not completely reliable.

 

What would be great is if we could replace the autohotkey script and make the app bring act to the front, lookup the contact record and if possible even go to and select the history item, all from the outside of the application using the Act SDK.

 

So my question is: is what I want to do possible, and how would I get started on something like this.

 

 

Platinum Elite Contributor
Posts: 14,384
Country: Australia

Re: Influencing the Sage Act application from the outside.

I think you'd need part of your app that controls the UI to be a plugin ... but you can send it info from an app outside.

Not sure if you can select a specific history item
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Influencing the Sage Act application from the outside.

You could look into Windows Communication Foundation class (WCF). It will allow communication between two applications (endpoints service). You need to write a plugin for ACT! (hosted service) and add code to your application (client service)

 

http://msdn.microsoft.com/en-us/library/ms731082.aspx

 

WCF was added in .NET 3.0

 

Hope this helps

-- Jim Durkin

Copper Contributor
Posts: 150
Country: Belgium

Re: Influencing the Sage Act application from the outside.

[ Edited ]

I've been on a small vacation and just got back.

Thanks for the info so far. Decided on doing some tests with a small plugin.

 

At first it seemed rather sucessful, I parse the GUID of the contact from my external application, lookup the record in the plugin, and show it.

 

The record shows up the first few times, but after a few consecutive attempts it stops working.

 

Private Sub GoToContactRecord(ByVal ID As Guid)
    Dim UsrContact As Contact = Nothing
    UsrContact = ActApp.ActFramework.Contacts.GetContactsByID(Nothing, {ID})(0)

    MsgBox("Before ShowContact FullName: " & UsrContact.FullName & " & GUID: " & UsrContact.ID.ToString)
    ActApp.UIContactManager.ShowContact(UsrContact)
    MsgBox("After ShowContact GUID:" & ActApp.ApplicationState.CurrentContact.ID.ToString)
End Sub

 

So in the first message box it shows the full name and GUID of the contact i'm trying to show, this keeps working so it's not the lookup that fails.

 

When it doesn't work, in the second messagebox I get the guid of the record I was on, not the record I tried to go to. So afaik calling the following line several times seems to fail. Any reason for that?

 

ActApp.UIContactManager.ShowContact(UsrContact)

 

 

A little more info, I used a TCP/IP class I used in another project to have both programs exchange data, once a message comes in on the plugin, and it's a GUID, it raises an event. The event gets caught in the main class of the plugin which executes above routine trying to select the contact.

Copper Contributor
Posts: 150
Country: Belgium

Re: Influencing the Sage Act application from the outside.

Anyone have an idea on this? It's driving me nuts.

 

At times it will even go to the contact but show the history of the old one.

Or go to the contact, and only update some fields, like you'll see the name and fax of the new contact, but the phone number of the old contact.

 

Is there a better way to make act move to a certain contact from within a plugin? Am I doing something wrong?

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Influencing the Sage Act application from the outside.

Have your tries to refresh the view after moving the contact?

ActApp.RefreshView("Act.UI.IContactListView")

There is also a method to refresh the current view you could try.

 

Maybe you could try moving the contactList pointer to the contact.

ActApp.ApplicationState.CurrentContact = myContact

 

Hope this helps

-- Jim Durkin

Copper Contributor
Posts: 150
Country: Belgium

Re: Influencing the Sage Act application from the outside.

Thanks for the reply, I tried your suggestions, a few combinations, none providing a full solution though.

 

Private Sub GoToContactRecord(ByVal ID As Guid)
    Dim UsrContact As Contact = ActApp.ActFramework.Contacts.GetContactsByID(Nothing, {ID})(0)

    Dim Before As Guid = ActApp.ApplicationState.CurrentContact.ID
    Dim GoingTo As Guid = ID

    ActApp.UIContactManager.ShowContact(UsrContact)
    ActApp.ApplicationState.CurrentContact = UsrContact
    ActApp.RefreshView("Act.UI.IContactListView")
    ActApp.RefreshView("Act.UI.IContactView")
    ActApp.RefreshView("Act.UI.IContactDetailView")
    ActApp.RefreshLoadedViews()

    Dim After As Guid = ActApp.ApplicationState.CurrentContact.ID

    MsgBox("Before: " & Before.ToString & ControlChars.NewLine & "GoingTo: " & GoingTo.ToString & ControlChars.NewLine & "After: " & After.ToString)

End Sub

 

This is the sub's code for now, threw in some other views to refresh just to make sure.

 

The first time it usually works completely, after that it does seem to update the ActApp.ApplicationState.CurrentContact, but fails to refresh the data on the screen. So still the history/activities/details of the first contact on which it worked.

 

So the GUID of the currentcontact updates, even the contact index on top of the screen (next to the detail/list view buttons) updates to the index of the contact. Just the data and history doesn't update.

 

 

Copper Contributor
Posts: 150
Country: Belgium

Re: Influencing the Sage Act application from the outside.

I hate replying to my own post and thus double posting, but I fear an edit would get missed and receive no replies.

 

It seems that the first time the sub is entered, the refresh works as it should, and you can actually see the history grid blink for half a second or so while the refresh does it's work.

 

The second time however, the refresh doesn't seem to happen. Even though it's called.

 

Removed most of the testing junk from the sub, looks like this now:

        Private Sub GoToContactRecord(ByVal ID As Guid)
            ActApp.UIContactManager.ShowContact(ActApp.ActFramework.Contacts.GetContactsByID(Nothing, {ID})(0))
            ActApp.CurrentView.RefreshView()
        End Sub

 

Even the ActApp.CurrentView.RefreshView() is unnecesary seeing as the ShowContact sub does a refresh, but seemingly only the first time.

 

Every time I call the sub though, the "CurrentContactChanged" event is raised, so Act receives the request to go to the other contact, it just doesn't refresh the view anymore after the first time.

 

I seriously can't see where i'm going wrong here.

 

Does anyone have any ideas, tips, things you want me to test?

Employee
Posts: 1,163
Country: USA

Re: Influencing the Sage Act application from the outside.

Hello EP, 

 

I'm not getting the same results with ShowContact, I used the code below to iterate through a ContactList and the refresh occurs each time the method is called:

 

private void ShowContact( )
        {            
            ContactList cl = _ActApp.ActFramework.Contacts.GetContacts(null);
            
            if (_ActApp.ApplicationState.CurrentContact.FullName == cl[index].FullName)
            {
                index++;
            }
            this._ActApp.UIContactManager.ShowContact(cl[index]);           
        }

Each time this moves to the next contact in the list and refreshes the data on the tabs. 

 

Is the Ui not refreshing and showing the correct contact? Is CurrentContact not updating? Or is it just the history tab that's failing to refresh?

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 150
Country: Belgium

Re: Influencing the Sage Act application from the outside.

First time the sub's called, the UI refreshes, the contact details on top are updated aswell as the history/activities and so on.

ActApp.ApplicationState.CurrentContact is also updated.

 

After that the UI doesn't refresh consistently, sometimes it'll only refresh the name, but leave the phone numbers/email and other fields of the previous contact.

 

Sometimes it just doesn't refresh at all.

 

However, ActApp.ApplicationState.CurrentContact always seems to update to the correct value.

Also the index on top of the detail view (showing what number contact you're on, for example 4853 of 14883) also refreshes to the correct index.

 

Changing layouts manually seems to update the ui to the correct contact it should be showing.