Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, June 28, 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!
 Web Forums - SalesLogix Web Client (Pre-7.2)
Forum to discuss using & developing the legacy SalesLogix Web Client (For versions 7.0 and earlier). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Client (Pre-7.2) | New ThreadView:  Search:  
 Author  Thread: Update Contact Form with field from contact overflow table
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Dec 06 12:12 PM
fiogf49gjkf0d
I have a table C_Contact which is a one to one join with the contact table. In this table I have a notes field I would like to add to the contact detail form. My field is not updating - I assume I need to modify the updatecontact action, but I am not sure what I need to do.. I created an alias for the field and added a text area to the contact detail template. I don't recall covering updates like this in the slx web class.

This is the code from updatecontact action:
Sub Main

StripPhone "cphwork","Work Phone #"
StripPhone "cphfax","Fax #"
StripPhone "cphmobile","Mobile Phone #"
StripPhone "cphhome","Home Phone #"
StripPhone "cphpager","Pager #"
SQLClause = "SELECT ACCOUNTID FROM CONTACT WHERE CONTACTID = '" & PostedGetValue("id") & "'"
accid = DoSQL(SQLClause, "0", "")

if PostedGetValue("conpri") = "T" then
cphandle = CreateRecord("UPDATE CONTACT")
LogSetGlobalId cpHandle, accid
RecordAddCondition cphandle, "accid", "=", accid
RecordAdd cpHandle, "conpri", "F"
PostRecord(cpHandle)
end if

LogSetGlobalId dbHandle, accid
DoUpdate "Contact", "conid"

End Sub

How do I get my custom field to update? Thanks
[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Dec 06 3:05 PM
fiogf49gjkf0d
Steve,

The updatecontact action uses the global sub "DoUpdate", which is in the action named "global". You actually won't need to write code if you do the following.

1) Create an alias that starts at the contact table and goes to your 1:1 table via a join. You probably have a global join and can use that. Don't use an underscore in the alias name - there is (at least was, unless it's been fixed) a bug that caused the web DLL to (silently) not work correctly if an alias has an underscore.
2) Put your HTML control on the form, and, for the name of the control, use the same name as your alias. You must do this.

That should do it. What happens in "DoUpdate" is that it calls "AddPostedValues", which is where the "magic" happens. AddPostedValues gets the name of each posted HTML control (in a loop). It looks to see if there is an alias that matches the control name. If it finds a match, it looks to see if that alias' main table is the table being updated (see the WAPI "AliasToTable" - it's called in AddPostedValues). If that is a match it does the "RecordAdd" for you, using the PostedGetValue of the control. After it adds all the posted values this way, DoUpdate calls the "PostRecord" for you.

The key is to name your control the same as your alias and make sure the alias STARTS at the main table/table being updated.

That should do it.

Jeff
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Dec 06 4:00 PM
fiogf49gjkf0d
Jeff, that is exactly what I have done..

Here is my text area:
<textarea name="connotes" rows="4" cols="25"><#F name=connotes></textarea>

My alias is called connotes and the path is Contact.Contact2.Notes

Not sure where I am going wrong.. any advice appreciated. Thanks
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Dec 06 4:03 PM
fiogf49gjkf0d
Hey, my html tag rendered.. anywhat the text area is named . I noticed in the SLXProfiler that if I change a field on the contact screen, the update statement doesn't pickup the notes field if that is worth anything..
[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Dec 06 5:53 PM
fiogf49gjkf0d
Steve,

Do you actually have a record in contact2 for the given contact? If you don't it will fail every time and *never* tell you. Gotta' love the web DLL! I've had that bite me more than once. If you run


select * from contact2 where contactid = 'your_conid_here'


do you get any results? I'd manually insert a record into the table for a known test contact if there isn't and test. If you don't have that record, you're attempting to update a record that doesn't exist.

I would modify your addcontact action to make sure that you *always* add the 1:1 record for any extension table if you're not already. That way, an inner join won't break a query and you can avoid this issue.

If you do have a record in the extension table, then I'm not sure. I just recreated your scenario on a 6.2.3 eval with no issues. Let me know, though, what you find. Maybe something else will come to light...

Also, here is a script that will insert the basic audit fields into a 1:1 table. Just uncomment the exec (@SQL) before running and be sure that the @VARIABLE assignments match your table. I use the print statement to see the SQL that will be generated. Backup, too, before running, just in case.


-- Insert missing extension table records by changing the values for the maintable, exttable and idfield it can be used with any 1:1 tables.
DECLARE @MAINTABLE VARCHAR(255)
DECLARE @EXTTABLE VARCHAR(255)
DECLARE @MAINTABLE_IDFIELD VARCHAR(255)
DECLARE @EXTTABLE_IDFIELD VARCHAR(255)
DECLARE @SQL VARCHAR(2000)

SET @MAINTABLE = 'CONTACT'
SET @EXTTABLE = 'CONTACT2'
SET @MAINTABLE_IDFIELD = 'CONTACTID'
SET @EXTTABLE_IDFIELD = 'CONTACTID'

SET @SQL = 'INSERT INTO sysdba.' + @EXTTABLE + ' (' + @EXTTABLE_IDFIELD + ', CREATEUSER, CREATEDATE, MODIFYUSER, MODIFYDATE)
SELECT ' + @MAINTABLE_IDFIELD + ', CREATEUSER, CREATEDATE, MODIFYUSER, MODIFYDATE FROM sysdba.' + @MAINTABLE + ' A
WHERE NOT EXISTS (SELECT ' + @EXTTABLE_IDFIELD + ' FROM sysdba.' + @EXTTABLE + ' B WHERE A.' + @MAINTABLE_IDFIELD + '= B.' + @EXTTABLE_IDFIELD + ')'
print @SQL
-- exec (@SQL)


As an FYI, I added the values for the ID fields from each table in case you create a table that isn't created as a true saleslogix 1:1 table. An example: I have a table c_userinfo_misc - I didn't want to create it as a 1:1 off of userinfo, because SalesLogix auto-creates a global join that I didn't want. So, actually, C_USERINFO_MISCID is actually a SalesLogix userid, but SalesLogix doesn't view it as a 1:1 from userinfo, even though it is.

Jeff
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 2:07 AM
fiogf49gjkf0d
Great sql Jeff. Here is something that you can run in the Admin | Execute SQL feature so it will sync (unlike Jeff's friendly version, you will have to modify the table and column names to suit your needs)

INSERT INTO
Account_One_To_One_Table_Name
(AccountID, CreateDate, CreateUser, ModifyDate, ModifyUser)
SELECT
A.AccountID, A.CreateDate, A.CreateUser, A.ModifyDate, A.ModifyUser
FROM
Account A
LEFT JOIN Account_One_To_One_Table_Name AX ON AX.AccountID = A.AccountID
WHERE
AX.AccountID IS NULL
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 9:58 AM
fiogf49gjkf0d
Exactly the case - missing contact2 records. Thanks Jeff and Timmus. I will need a small wig to cover the hole in my hair I got scratching my head yesterday...
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 10:00 AM
fiogf49gjkf0d
Ok, so how do I make my add account/contact functionality in the web client add the record to the contact2 table? Hidden fields on the template? Thanks
[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 10:18 AM
fiogf49gjkf0d
Steve,

If there won't be any data from the add account/contact pages that gets inserted on the add of an /contact, you'll probably want to do what you suggested. I'd add a hidden CONTACT2.NOTES field. The only thing that I'm not sure of: will the web DLL realize it's blank/empty and not even attempt to do the insert? I hope not. Because if it does have that intelligence, you'll be forced to figure something else out. Like always have it hard-coded to have a dummy value and then after the insert, update it to null.

Jeff


[Reply][Quote]
Jeff Ballard
Posts: 326
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Dec 06 10:31 AM
fiogf49gjkf0d
Steve,

I just tested it - I put this on the conadd2 template:

<input type="hidden" name="connotes" value="">


It inserted my 1:1 record and left the notes blank, the key thing being that inserted my 1:1 record with contactid, createuser, createdate, modifyuser, modifydate populated to match the contact table.

Jeff
[Reply][Quote]
Steve Knowles
Posts: 657
Top 10 forum poster: 657 posts
 
Re: Update Contact Form with field from contact overflow tableYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Dec 06 8:36 AM
fiogf49gjkf0d
Worked on my system to. Thank Jeff!
[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): 6/28/2024 5:11:04 PM