本文介绍了从机会创建销售订单时填充自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SO屏幕(SO301000)上创建了一个自定义字段Contact。现在,当用户从机会屏幕创建销售订单时(CR304000),我需要填充这些字段。新的自定义字段联系人基于机会中选择的客户。我可以看到,当我按照设计的方式从机会创建销售订单时,会自动填充客户。但是,如何对自定义字段执行同样的操作。

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.

我尝试扩展现有的CreateSalesOrder方法,但似乎无济于事。

I have tried extending existing CreateSalesOrder method but it seems it is not helping.

联系查询(它会根据客户在SO中的选择进行刷新,但不会根据我从机会创建SO进行刷新)

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(它当我根据机会创建SO时,它可以按要求工作,但不会根据客户的选择进行刷新。)

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 { }

推荐答案

在此处找到类似的答案:

Similar answer found here: How to pass line item custom field value to sales order from opportunity?

可以将其从CROpportunity转换为SOOrder。 ..

Can be translated to something like this from CROpportunity to SOOrder...

public class CROpportunityMaintExtension : PXGraphExtension<OpportunityMaint>
{
    [PXOverride]
    public virtual void DoCreateSalesOrder(Action del)
    {
        PXGraph.InstanceCreated.AddHandler<SOOrderEntry>(graph =>
        {
            graph.RowInserting.AddHandler<SOOrder>((cache, args) =>
            {
                var soOrder = (SOOrder)args.Row;
                CROpportunity opportunity = PXResult<CROpportunity>.Current;

                // Copy logic here...

            });
        });

        del();
    }
}

这篇关于从机会创建销售订单时填充自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 10:04