Hi,I modified some modules, included "Accounts", "Users", "Contacts", by the way like this:1. modify BaseTables\ACCOUNTS_CSTM.1.sql to add custom columns.2. rebuild Views\vwACCOUNTS.1.sql and any views that reference to ACCOUNTS_CSTM and vwACCOUNTS.3. modify Procedures\spACCOUNTS_Update.1.sql to add the custom columns to the declaration and update the code to table "ACCOUNTS_CSTM" like this: if not exists(select * from ACCOUNTS_CSTM where ID_C = @ID) begin -- then insert into ACCOUNTS_CSTM ( ID_C , CUSTOM_COLUMN_1 , CUSTOM_COLUMN_2 ... ) values ( @ID , @CUSTOM_COLUMN_1 , @CUSTOM_COLUMN_2 ... ); end else begin update ACCOUNTS_CSTM set CUSTOM_COLUMN_1 = @CUSTOM_COLUMN_1 , CUSTOM_COLUMN_2 = @CUSTOM_COLUMN_2 ... where ID_C = @ID; end -- if;4. modify three functions in _code\SqlProcs.cs have the names : spACCOUNTS_Update(), spACCOUNTS_Update(), cmdACCOUNTS_Update. To add new variables to their declarations and add some code like this:
IDbDataParameter parCUSTOM_COLUMN_1 = Sql.CreateParameter(cmd, "@parCUSTOM_COLUMN_1" , "string", 255);5. modify Accounts\EditView.ascx.cs whose calls SqlProcs.spACCOUNTS_Update().6. maybe some small modification that I can't remember nowThe method above works quite well now.
My question is that: is it necessary to do steps 3 to 6?My question raised when I understand SplendidDynamic.UpdateCustomFields() maybe try to help me doing all nasty things already. When I go to the declaration of SplendidDynamic.UpdateCustomFields(), I think it may meet some problem when I utility drop down list to set the value of my custom columns. Now I use new DynamicControl(this, rowCurrent, "aColumnName").SelectedValue to get the value from drop down list, I have no idea of it would work or not to a drop down list.Since there is no clear document to explain all this, althought my method works quite well now, I want to hear explicit answer from the author. By the way, I don't use any admin function to add columns, since I think it would be more effective to modify sql code for me, (one reason is easier to deploy to customer environment and sync the state of both of development and production).With best regard,Dragoon
You have two options for adding custom fields. One is to do it online, the other is to use the spFIELDS_META_DATA_Insert procedure (which is used online). The reason is that the meta data record is necessary to allow the custom to field to be automatically updated when an account is saved.
exec dbo.spFIELDS_META_DATA_Insert null, null, 'ACCOUNT_HANDLER', 'Account Handler', 'ACCOUNT_HANDLER', 'Accounts', 'varchar', 40, 0, 0, null, null, 0;
You can modify the spACCOUNTS_Update procedure as you have done, but then it becomes more difficult to apply a SplendidCRM update.