private static void FillToDocumentAddress(PXCache docAddressCache, DocumentAddress docAddress, Address address)
        {
            if (address == null || docAddress == null)
            {
                return;
            }

            docAddressCache.SetValue <DocumentAddress.addressLine1>(docAddress, address.AddressLine1);
            docAddressCache.SetValue <DocumentAddress.addressLine2>(docAddress, address.AddressLine2);
            docAddressCache.SetValue <DocumentAddress.city>(docAddress, address.City);
            docAddressCache.SetValue <DocumentAddress.countryID>(docAddress, address.CountryID);
            docAddressCache.SetValue <DocumentAddress.state>(docAddress, address.State);
            docAddressCache.SetValue <DocumentAddress.postalCode>(docAddress, address.PostalCode);

            docAddressCache.Update(docAddress);
        }
        private void FillFromContact()
        {
            Contact relatedContact = PXSelect <
                Contact,
                Where <
                    Contact.contactID, Equal <Current <Document.refContactID> > > >
                                     .SelectSingleBound(Base, new[] { Documents.Current });

            Address relatedContactAddress = PXSelect <
                Address,
                Where <
                    Address.addressID, Equal <Current <Contact.defAddressID> > > >
                                            .SelectSingleBound(Base, new[] { relatedContact });

            DocumentContact docContact = Contacts.Cache.Current as DocumentContact;
            DocumentAddress docAddress = Addresses.SelectSingle(docContact.DefAddressID);

            FillToDocumentContact(Contacts.Cache, docContact, relatedContact);
            FillToDocumentAddress(Addresses.Cache, docAddress, relatedContactAddress);
        }