Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, May 3, 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!
 Data & Imports Forums - T-SQL & Queries
Forum to discuss general T-SQL questions and help with queries related to SalesLogix data. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to T-SQL & Queries | New ThreadView:  Search:  
 Author  Thread: Can I update the Contacts AcountID directly with a SQL update statement?
Robert Waite
Posts: 17
 
Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 22 Dec 08 12:17 PM
Hello,
Ive hit an issue where a user has managed to Mas forward contacts to a single account. So what we have now is many contacts pointing to the incorect account. I have come up with a SQL query that has found these contacts based on matching the contacts address to an account address. Therefor I have the correct account ID for each of the contacts with the problem.
My question is "What is the best method of correcting the contact account ID?"

Im entertaining the idea of just running a strait up SQL update to modify the AcountID for each contact.
I wanted to seek any advice before performing the attempt.
Thank in advance
Robert Waite
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 2:18 AM
Firstly, remember that if you have remotes, you'll need to use Tools / Execute SQL in the Administrator client to get the SQL to sync ...

To put your mind at rest about maintaining database integrity, I suggest you get yourself a test db, select a contact, turn on SLX Profiler, choose the Edit / Move function and then check the results in Profiler. This will show you exactly how the system would move a contact and will, hopefully, ensure that you do not miss anything.

Phil
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 7:48 AM
Much thanks Phil for the reply,
I'm new to working with SLX and my company is too frugal to send me out for training on the development side... (The stuff I love doing)

If I'm reading this right I should first figure out how to use the profile. (I would be great full if you could put me in the right direction in finding documentation on it) and from there it will depict how SLX performs the data updates. Then armed with that knowledge I should execute the SQL updates in administrator rather then SQL management studio as we do indeed use remotes.
Robert
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 11:32 AM
Phil,
The Profiler that you speak of, is this a SLX function of a SQL Server function that is accessed via the SQL Management Studio?
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 11:51 AM
I found the SLX profiler
Thanks for the lead on getting this resolved.
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 12:44 PM
Seems like there is allot of Inserts and Updates going on for a simple movement of a contact code to a different account.
I may be able to get this all into a stored procedure but I am now wondering if using a COM reference in a .NET console program would be the safest way of handling this.
Ive reference all the SLX COM references and performed a performed a search on contact in the Object browser to see if I might find a magical function I could tap into the Business Layer to handle the data changes. But I did not find one.

Would this be a possibility? Can anyone steer me in the right direction?
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 23 Dec 08 7:58 PM
Yep - it's not as simple as it appears because there are several related tables. As you are new to SLX you did well to ask the question here - just updating AccountID may appear to work, but it would probably orphan other records in the system, or at least leave some inconsistent records behind.

Although there is no 'magical function', there is a place that you could start and that is the

System:MoveContact form

(as long as you are V7+)

You could adapt the code behind this form to perform the move automatically, by creating a new custom function

I suggest that you do not use COM or stored procs. Updates performed in stored procs do not sync out to remotes.

Phil
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 24 Dec 08 10:13 AM
It never is as simple as it appears and I have enough experience to know that hasty fixes often results in huge headaches. which is why I want to find out how experienced SLX developers would handle these issues before I get trigger happy.
Question: If a Stored Procedure was used to fix the issue would cutting new databases resolve the remote issue?

We are getting the web client set up and will discontinue use of remote clients once we have that set up.

I'm going to look into finding the code behind for the System:MoveContactForm... I am hoping that I can host the function build from that code can be hosted in a .NET application as it is my preferred platform of implementing customizations.
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 25 Dec 08 3:20 AM
Quote:
Originally posted by Robert Waite

--snip--
Question: If a Stored Procedure was used to fix the issue would cutting new databases resolve the remote issue?
--Snip--


Yes - the amended data would be contained in the new remote database.

The code in System::MoveContact is written in VBScript, not VB.NET, so moving to .NET would require a near total rewrite

Phil.
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 Dec 08 10:30 AM
Ive found the code behind for the System:MoveContact and I have been analyzing the code for the InitForm Sub
I cannot find any reference that points to the SLX_DB class nor can I find any methods named GetNewRecordSet anywhere in the object browser.
Is this a method that only supports late binding?

objSlxDb = New SLX_DB
ConRS = objSlxDb.GetNewRecordSet

If I perform all my Updates using the SalsesLogix OLE DB provider will my remotes sync?

Sub InitForm(ByVal contactid)
Dim strSql, Contact, ConRS
'I cannot find an SLX_DB or any methods for GetNewRecordSet
'Anywhere in the object browser. I have referenced any known
'SLX refererence I can find.
objSlxDb = New SLX_DB
ConRS = objSlxDb.GetNewRecordSet

strSql = "SELECT CONTACTID, FIRSTNAME, LASTNAME, ACCOUNTID, ACCOUNT FROM CONTACT WHERE CONTACTID = '" & contactid & "'"
ConRS.Open(strSql, objSlxDb.Connection)
If ConRS.Fields("CONTACTID").Value <> "" Then
Contact = ConRS.Fields("LASTNAME").Value
If Contact <> "" Then
Contact = Contact & ", "
End If
Contact = Contact & ConRS.Fields("FIRSTNAME").Value
newaccountid = ConRS.Fields("ACCOUNTID").Value
oldcontactid = ConRS.Fields("CONTACTID").Value
newaccount = ConRS.Fields("ACCOUNT").Value
End If
oldaccount = newaccount
oldaccountid = newaccountid
doLessOptions()
populateAssignTo(oldaccountid)
ConRS.Close()
newcontactid = oldcontactid
ConRS = Nothing
End Sub
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Dec 08 8:56 AM
The System:SLX Database Support Script has the SLX_DB class, et al references.

We all found out the hard way that the only way to synchronize a move is to delete and add all necessary records.......it's kind of like a snowplow leading the way (the delete statement) and then you bring in the new record which is pointing to the new accountid.

Buy DevLogix immediately, big time saver/helper/training tool.
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Dec 08 9:37 AM
Much Thanks for the lead. This looks like a gold mine resource.
Which should I start with DevLogixIII.7 or DevLogixV which seems to be only Web Development?
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 30 Dec 08 4:19 PM
Ive got some code together and it is working on my test data.
I just wanted to get any last words of advice before I attempt to perform this on my production database.

From what I understand this will sync as I am using the SalesLogix OLE DB connection. I will cut new databases nonetheless to make sure the changes get out
Ive posted the code up so that I can retain the color formats for keywords so it is more pleasing to read.

http://www.robertwaite.net/code/MoveContact.htm
Link to Code Sample

Not sure what the best way to post links are
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 08 8:13 AM
A quick way to verify you have hit all the needed tables is to access the SECTableDefs
SELECT * FROM sysdba.sectabledefs where fieldname in ('contactid', 'entityid')
SELECT * FROM sysdba.sectabledefs where fieldname in ('accountid', 'entityid')

For a first run through on data checking: Use the Integrity Checker. That will give you an idea if the base table data is in order. However if you have customs; I would suggest you not run the "fix' portion without a strong understanding of your specific data structure and business rules.

If it is of any value at this point : I've built similar functions but started with the creation of views based on the sectabledefs information. Then built a script that ran a loop with a couple If / Then statements using the view data as my table and field variables.

Carla
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 08 9:15 AM
Carla,
I am very greatful for your advice and I will look into the sectabledefs when I get back on friday. I will also run the integrity checker on my test environment before i hit the production database.

At this point SalesLogix is stock without any customizations or defined business rules. It is just an expensive phone book at this point. Ive ordered the DevLogix III.7 and it is in the mail. I very much look forward to perusing it. I love development and I cant wait to sink my cerebral teeth into a new platform and integrating it to our MAS 200 system.

Robert
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 08 9:20 AM
Welcome to the SalesLogix Development Community!
[Reply][Quote]
Robert Waite
Posts: 17
 
Re: Can I update the Contacts AcountID directly with a SQL update statement?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Dec 08 12:33 PM
Thanks for the welcome
[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): 5/3/2024 3:26:17 AM