public static IContact GetIContact(Contact source) { if (source == null) { return(null); } var dest = new CRContact(); dest.BAccountID = source.BAccountID; dest.RevisionID = source.RevisionID; dest.IsDefaultContact = false; dest.FullName = source.FullName; dest.Salutation = source.Salutation; dest.Title = source.Title; dest.Phone1 = source.Phone1; dest.Phone1Type = source.Phone1Type; dest.Phone2 = source.Phone2; dest.Phone2Type = source.Phone2Type; dest.Phone3 = source.Phone3; dest.Phone3Type = source.Phone3Type; dest.Fax = source.Fax; dest.FaxType = source.FaxType; dest.Email = source.EMail; dest.NoteID = null; dest.Attention = source.Attention; return(dest); }
protected virtual void _(Events.FieldUpdated <Document, Document.allowOverrideContactAddress> e) { var row = e.Row as Document; if (row == null) { return; } DocumentAddress address = Addresses.SelectSingle(); DocumentContact contact = Contacts.SelectSingle(); if (contact != null) { Contacts.Cache.SetValue <DocumentContact.overrideContact>(contact, row.AllowOverrideContactAddress); PXCache cache = GetContactCache(); if (cache != null) { CRContact crContact = GetCurrentContact(); if (crContact != null) { cache.SetValue <CRContact.isDefaultContact>(crContact, row.AllowOverrideContactAddress != true); } } } if (address != null) { Addresses.Cache.SetValue <DocumentAddress.overrideAddress>(address, row.AllowOverrideContactAddress); PXCache cache = GetAddressCache(); if (cache != null) { CRAddress crAddress = GetCurrentAddress(); if (crAddress != null) { cache.SetValue <CRAddress.isDefaultAddress>(crAddress, row.AllowOverrideContactAddress != true); } } } Addresses.Cache.Update(address); Contacts.Cache.Update(contact); }
private static void ApplyChangesfromContactInfo(ServiceOrderEntry graphServiceOrderEntry, CRContact crContactRow, FSServiceOrder fsServiceOrderRow, ref bool somethingChanged) { if (crContactRow == null) { return; } if (fsServiceOrderRow.Attention != crContactRow.Title) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.attention>(fsServiceOrderRow, crContactRow.Title); somethingChanged = true; } if (fsServiceOrderRow.EMail != crContactRow.Email) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.eMail>(fsServiceOrderRow, crContactRow.Email); somethingChanged = true; } if (fsServiceOrderRow.Phone1 != crContactRow.Phone1) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.phone1>(fsServiceOrderRow, crContactRow.Phone1); somethingChanged = true; } if (fsServiceOrderRow.Phone2 != crContactRow.Phone2) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.phone2>(fsServiceOrderRow, crContactRow.Phone2); somethingChanged = true; } if (fsServiceOrderRow.Phone3 != crContactRow.Phone3) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.phone3>(fsServiceOrderRow, crContactRow.Phone3); somethingChanged = true; } if (fsServiceOrderRow.Fax != crContactRow.Fax) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.fax>(fsServiceOrderRow, crContactRow.Fax); somethingChanged = true; } }
public static void UpdateServiceOrderHeader( ServiceOrderEntry graphServiceOrderEntry, PXCache cache, CROpportunity crOpportunityRow, FSCreateServiceOrderOnOpportunityFilter fsCreateServiceOrderOnOpportunityFilterRow, FSServiceOrder fsServiceOrderRow, CRContact crContactRow, CRAddress crAddressRow, bool updatingExistingSO) { bool somethingChanged = false; FSSrvOrdType fsSrvOrdTypeRow = GetServiceOrderType(graphServiceOrderEntry, fsServiceOrderRow.SrvOrdType); if (fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT) { if (fsServiceOrderRow.CustomerID != crOpportunityRow.BAccountID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.customerID>(fsServiceOrderRow, crOpportunityRow.BAccountID); somethingChanged = true; } if (fsServiceOrderRow.LocationID != crOpportunityRow.LocationID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.locationID>(fsServiceOrderRow, crOpportunityRow.LocationID); somethingChanged = true; } } if (fsServiceOrderRow.BranchID != crOpportunityRow.BranchID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchID>(fsServiceOrderRow, crOpportunityRow.BranchID); somethingChanged = true; } if (fsServiceOrderRow.BranchLocationID != fsCreateServiceOrderOnOpportunityFilterRow.BranchLocationID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchLocationID>(fsServiceOrderRow, fsCreateServiceOrderOnOpportunityFilterRow.BranchLocationID); somethingChanged = true; } if (fsServiceOrderRow.ContactID != crOpportunityRow.ContactID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.contactID>(fsServiceOrderRow, crOpportunityRow.ContactID); somethingChanged = true; } if (fsServiceOrderRow.DocDesc != crOpportunityRow.Subject) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.docDesc>(fsServiceOrderRow, crOpportunityRow.Subject); somethingChanged = true; } if (fsServiceOrderRow.ProjectID != crOpportunityRow.ProjectID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.projectID>(fsServiceOrderRow, crOpportunityRow.ProjectID); somethingChanged = true; } if (crOpportunityRow.OwnerID != null) { if (crOpportunityRow.OwnerID != (Guid?)cache.GetValueOriginal <CROpportunity.ownerID>(crOpportunityRow)) { int?salesPersonID = GetSalesPersonID(graphServiceOrderEntry, crOpportunityRow.OwnerID); if (salesPersonID != null) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.salesPersonID>(fsServiceOrderRow, salesPersonID); somethingChanged = true; } } } if (fsServiceOrderRow.OrderDate != crOpportunityRow.CloseDate) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.orderDate>(fsServiceOrderRow, crOpportunityRow.CloseDate); somethingChanged = true; } ApplyChangesfromContactInfo(graphServiceOrderEntry, crContactRow, fsServiceOrderRow, ref somethingChanged); ApplyChangesfromAddressInfo(graphServiceOrderEntry, crAddressRow, fsServiceOrderRow, ref somethingChanged); if (fsServiceOrderRow.TaxZoneID != crOpportunityRow.TaxZoneID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.taxZoneID>(fsServiceOrderRow, crOpportunityRow.TaxZoneID); somethingChanged = true; } if (somethingChanged && updatingExistingSO) { graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow); } }