2/21/2025 9:58:41 PM
|
|
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!
Forum to discuss using & developing the legacy SalesLogix Web Client (For versions 7.0 and earlier). View the code of conduct for posting guidelines.
|
|
|
|
Update Contact Form with field from contact overflow table
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 |
|
|
|
Re: Update Contact Form with field from contact overflow table
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
|
|
|
|
Re: Update Contact Form with field from contact overflow table
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 |
|
|
|
Re: Update Contact Form with field from contact overflow table
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.. |
|
|
|
Re: Update Contact Form with field from contact overflow table
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
|
|
|
|
Re: Update Contact Form with field from contact overflow table
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 |
|
|
| |
| |
|
Re: Update Contact Form with field from contact overflow table
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
|
|
|
|
Re: Update Contact Form with field from contact overflow table
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
|
|
|
| |
|
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!
|
|
|
|
|
|
|
|