Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Creating an contact group which displays contacts not contacted within the last 'x' number of days.
Gabe
Posts: 6
 
Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 3:58 PM
fiogf49gjkf0d
I was hoping some one could help me out with this. I've found a Link on support.saleslogix.com but info they gave isn't working for me. I've listed the link below.

http://support.saleslogix.com/kb/v52/sales/04170210.php3

I followed all of the steps in the link above and I've even tried the following:
Select distinct ContactId from History where DateDiff(day, Createdate,GetDate()) < 90
Select distinct ContactId from History where DateDiff(day, Createdate,GetDate()) > 90
Select distinct ContactId from History where (Not(DateDiff(day, Createdate,GetDate()) < 90))

Is there anyone out there that has a group setup that will display contacts not contacted in the last 90 days?

Thank you,
Gabe
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:21 PM
fiogf49gjkf0d
What version of SalesLogix are your running?

Your backend database is MSSQL... correct?
[Reply][Quote]
Gabe
Posts: 6
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:27 PM
fiogf49gjkf0d
I'm sorry about that Frank...
I'm running Version 6.2.1.3129
and Yes my backend database is MSSQL.

Thank you,
Gabe
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:44 PM
fiogf49gjkf0d
select contactid from contact where contactid in (select distinct contactid from history where ...)

... = Your DateDiff or whatever other code you wish to call against the "child" table in this instance. Each of the TACO groups must be relative to their table (contact/contactid) so you always have to return any result relative to those base tables.

If you were on 6.2.3+ you could use the SLX Profiler. What I do is I'll make a group and profile it's SQL (or the SQL of an existing group). I'll modify the SQL in Query Analyzer so that it runs then reverse engineer that into the proper group layout, sort order, and conditions. Doing this for every group is overkill but it may be necessary for those groups that have SQL that just isn't showing up the way you want it to.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:46 PM
fiogf49gjkf0d
Another caveat to the "not contacted" debate is the fact that DB Change records are inserted in the history table, so you have to also segregate the data by type of history to make sure it's not that someone changed Firstname "Bob" to "Robert".
[Reply][Quote]
Tim Montgomery
Posts: 23
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:48 PM
fiogf49gjkf0d
did you use the contactid?
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 4:55 PM
fiogf49gjkf0d
Quote:
Originally posted by Gabe

I'm sorry about that Frank...
I'm running Version 6.2.1.3129
and Yes my backend database is MSSQL.

Thank you,
Gabe


Questions:
1. Did you check the "use value as literal" option?
2. Did you put ( ) around your SQL?

After you create your group do a VIEW SQL and post the results here


[Reply][Quote]
Gabe
Posts: 6
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 5:17 PM
fiogf49gjkf0d
Frank to your questions

1. No, I didn't check "use value as literal".
2. No, I didn't put ( ) around the SQL. But when I click OK it will put them automatically.

Here is the View SQL statement:
SELECT DISTINCT A1.CONTACTID, A1.NAMELF, A1.ACCOUNT, A1.WORKPHONE, A1.EMAIL, A1.ACCOUNTMANAGERID FROM CONTACT A1 WHERE (A1.ACCOUNTMANAGERID='U6UJ9A000007') AND NOT (A1.CONTACTID IN (SELECT DISTINCT contactid FROM sysdba.HISTORY WHERE (DATEDIFF([day], CreateDATE, GETDATE()) < 90))

I have also tried
SELECT DISTINCT A1.CONTACTID, A1.NAMELF, A1.ACCOUNT, A1.WORKPHONE, A1.EMAIL, A1.ACCOUNTMANAGERID FROM CONTACT A1 WHERE (A1.ACCOUNTMANAGERID='U6UJ9A000007') AND (A1.CONTACTID IN (SELECT DISTINCT contactid FROM sysdba.HISTORY WHERE (DATEDIFF([day], CreateDATE, GETDATE()) > 90))

and

SELECT DISTINCT A1.CONTACTID, A1.NAMELF, A1.ACCOUNT, A1.WORKPHONE, A1.EMAIL, A1.ACCOUNTMANAGERID FROM CONTACT A1 WHERE (A1.ACCOUNTMANAGERID='U6UJ9A000007') AND (A1.CONTACTID IN (SELECT DISTINCT contactid FROM sysdba.HISTORY WHERE (NOT (DATEDIFF([day], CreateDATE, GETDATE()) < 90)))

When I use the last two statements I get results but they aren't accurate. They will show contacts that have had updates within the last 90 days.

Thank You all for your help and quick replies!
-Gabe
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 5:17 PM
fiogf49gjkf0d
I just created a group to show contacts with history records created in the last 90 days.

Here is how I built my condition:

Field: Contact.ContactID
Operator: IN
Value is: (select contactid from history where history.startdate > GetDate()-90)
Use Value as literal (checked)

Here is what I see in View SQL:
SELECT A1.CONTACTID, A1.ACCOUNT, A1.LASTNAME FROM CONTACT A1 WHERE (A1.CONTACTID IN (select contactid from history where history.startdate > GetDate()-90))


[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 5:56 PM
fiogf49gjkf0d
Gabe,

Others may correct me, but I'm going to guess the DateDiff is going to cause the provider to choke. I don't believe it's ANSI SQL compliant. I think you're going to have to find another way. I haven't actually done anything like that group, though.

Jeff
[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Jul 06 5:56 PM
fiogf49gjkf0d
Gabe,

Others may correct me, but I'm going to guess the DateDiff is going to cause the provider to choke. I don't believe it's ANSI SQL compliant. I think you're going to have to find another way. I haven't actually done anything like that group, though.

Jeff
[Reply][Quote]
Gabe
Posts: 6
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jul 06 12:39 PM
fiogf49gjkf0d
Quote:
Originally posted by Frank Chaffin

I just created a group to show contacts with history records created in the last 90 days.

Here is how I built my condition:

Field: Contact.ContactID
Operator: IN
Value is: (select contactid from history where history.startdate > GetDate()-90)
Use Value as literal (checked)

Here is what I see in View SQL:
SELECT A1.CONTACTID, A1.ACCOUNT, A1.LASTNAME FROM CONTACT A1 WHERE (A1.CONTACTID IN (select contactid from history where history.startdate > GetDate()-90))




Frank, it worked great but I did have to make a few changes:

1. Added "DISTINCT"
2. Left "Use Value as Literal" UNCHECKED (Didn't get any results when checked).
3. Added "AND (NOT ContactId = '' OR ContactId = NULL)". Because without it, I wouldn’t get anything.

What I used:
SELECT DISTINCT CONTACTID FROM sysdba.HISTORY WHERE (MODIFYDATE > GETDATE() - 90) AND (NOT ContactId = '' OR contactid = NULL)

View SQL:
SELECT DISTINCT A1.CONTACTID, A1.NAMELF, A1.ACCOUNT, A1.WORKPHONE, A1.EMAIL, A1.ACCOUNTMANAGERID, A1.NAMELF FROM CONTACT A1 WHERE NOT (A1.CONTACTID IN (SELECT DISTINCT CONTACTID FROM sysdba.HISTORY WHERE (MODIFYDATE > GETDATE() - 90) AND (NOT ContactId = '' OR contactid = NULL))) AND (A1.ACCOUNTMANAGERID=:USERID) ORDER BY A1.NAMELF ASC

Thank you all for your help!
-Gabe
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jul 06 3:39 PM
fiogf49gjkf0d

I am Glad it worked out for you. Adding the DISTINCT clause and the other clauses is a good idea.

Should "AND (NOT ContactId = '' OR contactid = NULL)" be "AND (NOT (ContactiID = '' OR contactid = NULL))"?

BTW, you should not need the sysdba. prefixes but it won't cause a problem.
[Reply][Quote]
Gabe
Posts: 6
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jul 06 5:27 PM
fiogf49gjkf0d
When I write it out like "AND (NOT ContactId = '' OR contactid = NULL)" SQL will do all of the extra work for me by formatting it correctly.... lazy, I know and I'm sure that it will bite me in the ass one day down the road (probably when SQL 2007 comes out), but it works for now.

When I used the statement like you gave "AND (NOT (ContactiID = '' OR contactid = NULL))" I did not get any results, don't know why.

Please correct me if I'm wrong, I don't want to mislead anyone. I'm still very new to SQL and SalesLogix. Thank you for your help!
-Gabe
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jul 06 8:28 PM
fiogf49gjkf0d
According to the Slx help, when you check the Use as Literal option Slx should take the syntax as you entered it. If you don't check this option Slx tries to figure out what you want to do. Some times this results in different behavior than I want. The behavior can also vary between different versions of Slx.

In any event just make sure that you cross test with Query Analyzer to verify that the proper records are being sourced.
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jul 06 8:20 AM
fiogf49gjkf0d
Query Analyzer might not be the best place to test results. Use the Administrator SQL to test. This will guarantee the sql statement is compatible with the provider.

John G.
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jul 06 9:24 AM
fiogf49gjkf0d
Quote:
Originally posted by John Gundrum

Query Analyzer might not be the best place to test results. Use the Administrator SQL to test. This will guarantee the sql statement is compatible with the provider.

John G.


John,

My point was to verify that the results returned by the Slx Provider are correct. To do that he needs to take the provider out of the picture. To do that in MSSQL databases I use the MSSQL's Query Analyzer.

Does this make sense?
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Jul 06 7:02 AM
fiogf49gjkf0d
Time to revisit. I knew we had something here that showed accounts or contacts with no activity since x date. I finally got around to digging for it and found an Account group tab called 'No Activity Since 2004'. When I looked at the condition I found it had only one condition. A very simple one.

NOT Account.Accountid in (SELECT * FROM c_AccountNoActivity) True END

Editing the condition showed the value as

SELECT * FROM c_AccountNoActivity

and the 'Use Value as a Literal' is NOT checked.

That rung a bell in my head (it reverberated for quite sometime :p ). I recalled that it was easier to create a view of all account IDs that had some kind of activity or history. This required the use of a UNION to join the results of the history and activity tables. The view in SQL Server looks like this

SELECT DISTINCT ACCOUNTID
FROM sysdba.HISTORY
WHERE (ACCOUNTID LIKE 'A%') AND (CREATEDATE >= '01/01/2004')
UNION
SELECT DISTINCT ACCOUNTID
FROM sysdba.ACTIVITY
WHERE (ACCOUNTID LIKE 'A%') AND (CREATEDATE >= '01/01/2004')

All it does is return the account IDs with history or activity where the createdate is greater than 1/1/2004. The NOT in the account group condition reverses the logic to show accounts not in the view.

This method solved a few issues.

1) It solved the issue with using UNIONs through the provider (I've heard its not supported .. maybe thats changed)
2) It simplified the condition and readability in SLX.
3) It put the business logic on the backend. Which is better. It can be called anytime from anywhere.
4) It avoids any provider incompatibilities

So from the looks, all you would have to do is change the WHERE conditions to do a DATEDIFF() or what ever condition you require.

John G.

[Reply][Quote]
Michael Kirkpatrick
Posts: 3
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jul 06 8:33 AM
fiogf49gjkf0d
Thanks for the simplified solution...all I had to do was in the Where clause for Create date > = was use DATEADD(dd,-90,GetDate())....that gave me history/activities in last 90 days!
[Reply][Quote]
John Gundrum
Posts: 632
Top 10 forum poster: 632 posts
 
Re: Creating an contact group which displays contacts not contacted within the last 'x' number of days.Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Jul 06 9:50 AM
fiogf49gjkf0d
Oh, something else is that I'm using the accountID. I believe you wanted the contactID. If you really want to show it at the contact level the view would look like

SELECT DISTINCT CONTACTID
FROM sysdba.HISTORY
WHERE (CONTACTID LIKE 'C%') AND (CREATEDATE >= DATEADD(dd,-90,GetDate()))
UNION
SELECT DISTINCT CONTACTID
FROM sysdba.ACTIVITY
WHERE (CONTACTID LIKE 'C%') AND (CREATEDATE >= DATEADD(dd,-90,GetDate()))
<.PRE>

John G.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 7:21:59 AM