Solved

Customers with alerts - v15.4

  • 23 August 2023
  • 5 replies
  • 63 views

Userlevel 6
Badge +11

Hi all

My backoffice team have asked if there is a way to find all customers with active alerts. From what I can see, this is not visible except looking at the attachements on the customer. Any easy way to find this? Or will I need to create a SQL-script?

icon

Best answer by Reid Gilbert 23 August 2023, 14:28

View original

5 replies

Userlevel 7
Badge +15

I’m not aware of a way to identify those all directly within the application but you can probably get that info quickly directly from the ap_attachments table at the database level with a script like the following (you may need to add a check for the ap_from_date just in case there are alerts with a future start date but this should get you close):

 

select distinct ap_table_key from ap_attachments with(NOLOCK) where ap_table_name = 'cust' and ap_is_alert = 'Y' and ap_to_date > Getdate();

Userlevel 6
Badge +11

Excellent - thank you, Reid!

Userlevel 7
Badge +21

Thanks, Reid….

Might I suggest that you also account for the possibility the ap_to_date is null or the row won’t pull up in the cases where no dates were defined within the alert definition.

select disinct ap_table_key from ap_attachments with(nolock) where ap_table_name = ‘cust’ and ap_is_alert = ‘Y’ and (ap_to_date > getdate() or ap_to_date is null)

 

Userlevel 7
Badge +15

Quick note: Phil just pointed out that there could be alerts without any date values entered so be sure to account for those as well in your testing

Userlevel 6
Badge +11

@Reid Gilbert and @Phil Seifert - users baffled by “my” data mining skills. Thanks!

Reply