It really was not that difficult to add a custom field to the line items. In the table, we added a new TemplateField column added the field to both the ItemTemplate and the EditItemTemplate.
<asp:TemplateField HeaderText="Service Date"> <ItemTemplate><%# Eval("SERVICE_DATE_C") %></ItemTemplate> <EditItemTemplate> <asp:TextBox ID="SERVICE_DATE_C" Text='<%# Eval("SERVICE_DATE_C") %>' Width="60" autocomplete="off" runat="server" /> </EditItemTemplate> </asp:TemplateField>
We then added code to methods grdMain_RowUpdating and LoadLineItems. We mostly just copied the code that managed the DESCRIPTION field and did the exact same thing for SERVICE_DATE_C. Just search EditLineItemsView.ascx.cs for "DESCRIPTION" and add your custom field to the next line.
In order for the custom field to get updated when the Order is saved, you will have to use our function to add the custom field to the system. The following function performs an alter table to add the actual field to the custom table, and it adds a record to the FIELDS_META_DATA table, which is required for automatic updating of custom fields.
exec dbo.spFIELDS_META_DATA_Insert null, null, 'SERVICE_DATE', 'Service Date', 'SERVICE_DATE', 'ORDERS_LINE_ITEMS', 'date', null, 0, 0, null, null, 0;
This is sweet! Thanks for posting this, it really helps. The part I couldn't figure out was the stored procedure to update the meta fields table. Would I just replace the the 'date' type with decimal to make mine work? I even created a java function to manage the onblur event of the field to update the subtotal with the discount %.
Still, I 'm curious why my Discount field in the Quotes table updates correctly and yet the Discount_USDollar field is updating with the subtotal now? I know it's not the code. Any thoughts or ideas ideas what may have occured in the database?
You may need to go directly to get database to confirm what you are saying about Discount_USDollar. I still believe that the problem is not that the field is getting updated imporperly, but that the view is old and needs to be recompiled.
Custom fields are not updated using a stored procedure. We go directly to the _CSTM table.
<%# Eval("SERVICE_DATE_C") %>
OK, so I had a chance to go back and make this happen. Having a problem still updating the field using the function :UpdateCustomFields(SplendidControl ctlPARENT, IDbTransaction trn, Guid gID, string sCUSTOM_MODULE, DataTable dtCustomFields)
I modified dtcustomfields to pull only line item custom fields et.c.., but I get into difficulty running the funtion, as this part:
DynamicControl ctlCustomField = new DynamicControl(ctlPARENT, sNAME);if ( ctlCustomField.Exists )........
......
causes me grief. Of course, the line item control is not in the ctlPARENT control and I'm not sure of a work around on this one? Any suggestions?
Thanks again!
Can you email the code to our support staff? We might be able to spot the problem quickly if we have the source.