Page 1 of 1

Obtaining selected Delivery address record from sales order

PostPosted: Wed May 04, 2016 12:31 pm
by indikad
I am on sales order screen using the SalesOrderHistory object on the sales order SaveStart event
user has selected a NON default delivery address.
I need to to obtain the "EDI Store Location Code" value ( This field - that is on debtor master deliver address tab ) for the selected delivery address.

However , the SalesOrderHistory does not contain that value , it contains Address 1 , Address 2 etc but not this one.

I am currently querying the DB_DeliveryAddress table based on the selected Address 1 - but this is not the best outcome for me as I have to restrict the user from editing the Address 1 field on sales order

any ideas ?

Re: Obtaining selected Delivery address record from sales or  Topic is solved

PostPosted: Wed May 04, 2016 1:01 pm
by Scott.Pearce
It doesn't look like there is a tight link from sales order delivery address to debtor delivery address - a delivery address is selected from the lookup, and then denormalised into the sales order history table. Further, as you noted, the delivery address on the sales order can be changed to be any arbitrarily address!

What if you stored the DB_DeliveryAddress.DeliveryID in a Sales Order History custom field? Upon SO Create End, sql read in the DB_DeliveryAddress.DeliveryID for the default delivery address for the debtor. If _SalesOrder.SalesOrderHistorys(_SalesOrder.SelectedHistoryNo).DelAddress1 ever changes, attempt to read DB_DeliveryAddress.DeliveryID based on DebtorID and Address1. If a DB_DeliveryAddress.DeliveryID is found, update the custom field. If it is not found, then user must have overtyped the address1 - the existing custom field value is still valid and should remain untouched.

When you want to get the EDI Store Location Code, use the DeliveryAddress entity (JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.DeliveryAddress) - .ReadRecord() based on your custom field value, then look at the .EDIStoreLocationCode property of the entity.

Re: Obtaining selected Delivery address record from sales or

PostPosted: Wed May 04, 2016 1:23 pm
by indikad
Hi Scott,
<< JiwaFinancials.Jiwa.JiwaApplication.Entities.Debtor.DeliveryAddress) - .ReadRecord() >>
Thanks for the above - reminds me

the salesoder.debtor extension gives me the EDI Store Location ID at any time - so I wont need to save it in a custom field - (but that is from the Debtor Default address record and NOT what the sales order carries).
I currently achieve your way but using a SQL query checking DB_DeliveryAddress DB
(WHERE DB.AccountNo = 'account01' AND DA.Address1 = 'someaddress '

I guess the way its wired if the user is allowed to change Address fields on the sales order it wont make sense for you to keep a tight link.