Custom Fields on Order
Posted: Thu Mar 06, 2008 11:29 am
I would like to know the best way to add custom fields to an Order. I was considering a couple different approaches but both have negatives which I'm trying to avoid.
One of my requirements is to be able to filter an order by a custom field. For example, I need to add a new field to Order called PatientName. When I call OrderDataSource.LoadForCriteria(..) I need to filter by the PatientName field.
One suggestion I saw was to create a second table for the additional fields and use the OrderId as a foreign key on my custom table. The problem here is that I can’t search for an order using criteria from my custom table. It’s also a problem because I can’t show the data in the same result set. This forces me to display order first and then lookup the additional order information in a second query.
A second option is to extend the Order, OrderCollection and OrderDataSource classes. I could add new properties to the Order, and override the OrderDataSource methods. Then instead of using the CommerceBuilder.Orders.Order I could use my custom Order.
The preferred approach for us is to add new properties to the Order class and add the corresponding fields to the Orders table. Without source code, this isn’t possible either. I understand this breaks upgrade support and that's not an issue for us. We're using the API as a platform and starting point for a larger application.
I would appreciate feedback as to the best approach and the ones that adheres the closest to existing AC architecture.
Thanks!
One of my requirements is to be able to filter an order by a custom field. For example, I need to add a new field to Order called PatientName. When I call OrderDataSource.LoadForCriteria(..) I need to filter by the PatientName field.
One suggestion I saw was to create a second table for the additional fields and use the OrderId as a foreign key on my custom table. The problem here is that I can’t search for an order using criteria from my custom table. It’s also a problem because I can’t show the data in the same result set. This forces me to display order first and then lookup the additional order information in a second query.
A second option is to extend the Order, OrderCollection and OrderDataSource classes. I could add new properties to the Order, and override the OrderDataSource methods. Then instead of using the CommerceBuilder.Orders.Order I could use my custom Order.
The preferred approach for us is to add new properties to the Order class and add the corresponding fields to the Orders table. Without source code, this isn’t possible either. I understand this breaks upgrade support and that's not an issue for us. We're using the API as a platform and starting point for a larger application.
I would appreciate feedback as to the best approach and the ones that adheres the closest to existing AC architecture.
Thanks!