Solved

Customer define default Reason Code

  • 3 November 2021
  • 2 replies
  • 153 views

Userlevel 2
Badge

I have created one selector custom field in Customers screen and managed to grab Reason Code information using the code below:

public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
{
#region UsrReasonCode
[PXDBString(CS.ReasonCode.reasonCodeID.Length, IsUnicode = true)]
[PXUIField(DisplayName="Reason Code")]
[PXSelector(typeof(Search<CS.ReasonCode.reasonCodeID,
Where<CS.ReasonCode.usage, Equal<ReasonCodeUsages.sales>,
Or<ReasonCode.usage, Equal<ReasonCodeUsages.issue>>>>),
DescriptionField = typeof(ReasonCode.descr), CacheGlobal = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string UsrReasonCode { get; set; }
public abstract class usrReasonCode : PX.Data.BQL.BqlString.Field<usrReasonCode> { }
#endregion
}
}

 

How can I grab the value set in the Customers screen and make it a default value in Sales Order screen. I have tried replacing the Reason Code field with the code below but failed to get the desired result:

[PXDBString(CS.ReasonCode.reasonCodeID.Length, IsUnicode = true)]
[PXSelector(typeof(Search<ReasonCode.reasonCodeID,
Where<Current<SOLine.tranType>, Equal<INTranType.transfer>, And<ReasonCode.usage,
Equal<ReasonCodeUsages.transfer>,
Or<Current<SOLine.tranType>, NotEqual<INTranType.transfer>, And<ReasonCode.usage,
In3<ReasonCodeUsages.sales, ReasonCodeUsages.issue>>>>>>), DescriptionField = typeof(ReasonCode.descr))]
[PXDefault(typeof(BAccountExt.usrReasonCode), PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Reason Code")]

 

icon

Best answer by EGolshtein67 3 November 2021, 15:18

View original

2 replies

Userlevel 2

Hi there,

Please try the code below:

[PXDefault(typeof(Search<BAccountExt.usrReasonCode, Where<BAccount.bAccountID, Equal<Current<SOOrder.customerID>>>)

 

As per help article:

You usually set the default value to a DAC field by using the PXDefault attribute. You can set a constant as the default value or provide a BQL query to obtain a value from the database or data records from the cache. The default value is assigned to the field when a data record that includes this field is inserted into the cache.

Userlevel 2
Badge

Hi @EGolshtein67 , the query works as a charm. I missed out on querying the PXDefault part there.Thanks a lot!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved