Last Activity Date for Account

I am trying to track the Last Activity for an account so we don’t lost contact with any of the accounts. We have accounts, then contacts associated with the accounts, and of course opportunities which are related to an account.
If we create or modify a call, task, note, meeting related to an account, I would like the Accounts Last Activity Date updated. This I can handle via a workflow.
If we create or modify a call, task, note, meeting related to an opportunity, I would like the Last Activity Date for the Account related to that opportunity to be updated.
If we create or modify a call, task, note, meeting related to a contact, I would like the Last Activity Date for the Account related to that contact to be updated.
Is there a way to do this? If I associate a call with an opportunity in a workflow, I can update the opportunity.last activity date, but i’m not sure how to modify the related accounts last activity date from here. Is there a way to do this or is this not possible. Using SuiteCRM v 7.10.22. Thanks

@st1
You can make global logic hook (after_save) for all modules which have relationship with account. Be careful with Accounts module. Don’t do an endless loop.

Hi @st1,

Welcome to the Community!! :tada:

There’s what @p.konetskiy said or you could try having a workflow for each action.

Workflow that when a change is made to the task updates a field on the opportunity
Then a workflow that when a change is made to the field on opportunity will update the accounts with that value.
Etc,
Etc,

Just plan it carefully to ensure you don’t make a loop and continually trigger workflow runs as that will have a detrimental effect on CRM performance.

Not the cleanest method but if you want to avoid code that might be your best option.

Hi @Mac-Rae!
I wrote about logic hook because @st1 can write one universal code for some (may be for all) modules. If you use workflow you should make logic for each module.

1 Like

Hi @p.konetskiy, I prefer your suggestion as it is more logically sound, just wanting to provide new members of the community different options for different skill levels.

1 Like

Hi @Mac-Rae
OK :slight_smile: I do not exactly understand you.

Lets not drag this side conversions on for much longer as i don’t want to distract from the topic.

You suggested creating a logic hook which is a better suggestion in my opinion as like you said you could use the same repeated functions and have the ability to customise and optimise it for performance.

However,

In following with what the OP has done so far, i suggested creating additional workflows that allows the update to be passed down the chain. For example if you updated a task assigned to an opportunity, that opportunity would be marked as updated and then the accounts would be updated because the opportunity was updated, etc. Multiple workflows would be required however still would not required any code.

Let me know if this helps :smile:

Thanks for the reply.

The idea of the workflows will work for the most part, with the exception of someone simply making an update to a contact or an opportunity. Then it would show as activity with the account even if they didn’t actually contact the account. It is better than nothing however, so it’s a good suggestion.
As for the code, it is php code, correct? I haven’t had the chance to look at that yet. I might start with the workflows and when I get a chance, explore the code more.

Thanks for the quick responses

Hi @st1,

Thinking if you used a specific custom field and check for changes in the field only. Therefore only the correct change will trigger the workflow. Worth looking into developing some skills with the code side of things as well tho, so ether suggestion works. Let us know if you run into any issues or need any assistance :+1:

Still working on this project. Made some progress, but running into a few issues, especially with email.

Would like to update a custom Last Activity Date (LAD) field for Accounts to make sure our Sales Professionals (SP) are following up with Leads and Customers. Anytime they send and email, make a Call, or setup a Meeting is considered an Activity. In the end, I will have two reports, one showing Accounts with no Activity in the last 30 days and another with Leads with no Activity in the last 30 days.

I have workflows for Calls (one for editing existing and another for a new call). I have Call workflow for any call Related To a Lead, Account, Contact, or Opportunity. Then a separate workflow to update the Account. For example, if a call is related to an Opportunity, the custom Opportunity LAD field is updated. This update triggers another workflow which updates the Account the Opportunity is related to.

Most of the time, this process works for Calls associated with Leads, Contacts, Accounts, and Opportunities. The only time it fails is if I create a Call using the Create button on the top menu bar and associate it with a Lead or a Contact. If I use this button and associate it with an Account or Opportunity it works. If I go directly to the Lead or Contact and create a call, then the process works as well, meaning the Lead or Contact LAD are updated which then kicks off a workflow and updates the Account LAD.

I duplicate the workflows for Emails and Meetings. When testing Meetings, it worked the same way the calls did. It worked as long as I didn’t use the Create button and assign the new meeting to a Lead or a Contact.

My problem has been with Emails. When I test the same way using Emails, it never works. It doesn’t matter how I am creating it or what I am Relating it To. It doesn’t work if I go to Activities and Compose an email or if I go directly to a Lead, Account, Contact, or Opportunity and create via the Activities subpanel there.

Any ideas as to what is different about the Emails module which is causing this? Thanks again.

Just an update, I couldn’t get emails working in the workflow like I did with Calls and Meetings, so I had the email workflow create a Note, put a specific phrase in the Description, then create another workflow triggered upon the creation or a Note with a Condition having the phrase in the Note Description, then update the associated Account with that. This worked, for MOST of them, but of course, not all of them. When I did this for emails associated with an account, opportunity, or lead it worked, but not when I created an email and associated it with a Contact. This is not the ideal way to set it up anyway, since I have a Note every time someone creates an email, but I just wanted to see if it worked. Lots of cleanup would be involved if I did it this way anyway. This system seems very inconsistent and somewhat frustrating, as it works with most things but not everything. I guess it’s time to try to learn the php on my own and see if I can figure out how to do it with hooks, etc, as described earlier. Otherwise I can use it to tell my SP’s that they haven’t followed up with an Account\Customer in the last 30 days, which is our main purpose of going to a CRM. Any further ideas are welcomed. Thanks again.