I have created a custom field Contact on SO screen (SO301000). Now I need to populate these field when user Create Sales Order from Opportunity screen (CR304000). New custom field Contact is based on Customer selected in Opportunity. I can see that Customer is automatically populated when I create Sales Order from Opportunity as it is by designed. However, how can I do that same for the custom field.
I have tried extending existing CreateSalesOrder method but it seems it is not helping.
Contact Lookup (It refreshes based on Customer select in SO but not when I create SO from Opportunity)
[PXDBInt()]
[PXUIField(DisplayName = "Contact", Visibility = PXUIVisibility.Visible)]
[PXSelector(typeof(Search2<Contact.contactID,
LeftJoin<BAccount2, On<BAccount2.bAccountID, Equal<Contact.bAccountID>>>>),
DescriptionField = typeof(Contact.displayName), Filterable = true, DirtyRead = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(Default<SOOrder.customerID>))]
[PXRestrictor(typeof(Where<Contact.contactType, NotEqual<ContactTypesAttribute.bAccountProperty>,
And<Where<BAccount2.bAccountID, Equal<Current<SOOrder.customerID>>,
Or<Current<SOOrder.customerID>, IsNull>>>>), PX.Objects.CR.Messages.ContactBAccountDiff)]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), PX.Objects.CR.Messages.ContactInactive,
typeof(Contact.displayName))]
public virtual int? UsrCustContactID { get; set; }
public abstract class usrCustContactID : IBqlField { }
Contact Lookup (It is working as required when I create SO from Opportunity but does not refreshes based on Customer selection)
[PXDBInt()]
[PXDBChildIdentity(typeof(Contact.contactID))]
[PXRestrictor(typeof(Where<Contact.isActive, Equal<True>>), "Contact '{0}' is inactive or closed.", new[] { typeof(Contact.displayName) })]
[PXSelector(typeof(Search2<Contact.contactID, LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>, Where<Contact.contactType, Equal<ContactTypesAttribute.person>, Or<Contact.contactType, Equal<ContactTypesAttribute.lead>>>>), DescriptionField = typeof(Contact.displayName), Filterable = true)]
[PXUIField(DisplayName = "Contact")]
public virtual int? UsrCustContactID { get; set; }
public abstract class usrCustContactID : IBqlField { }