Hi, @larryly Acumatica will not allow us to provide the static text on the PXDefault hence, we need to use the BQL constants.
I have modified your DAC filed PXDefault code, it seems there are some wrong conditions added.
Please find the updated DAC filed code below.
BQL Constants Class
public class AZConstants
{
public class BUYGROUP : PX.Data.BQL.BqlString.Constant<BUYGROUP>
{
public BUYGROUP() : base("BUYGROUP") { }
}
}
DAC Field:
#region UsrBuyingGroup
PXDBString(50, IsUnicode = true)]
PXUIField(DisplayName = "Buying Group")]
PXDefault(typeof(Search2<CSAnswers.value, LeftJoin<BAccount,
On<BAccount.noteID, Equal<CSAnswers.refNoteID>,
And<BAccount.bAccountID, Equal<Current<SOOrder.customerID>>>>>,
Where<CSAnswers.attributeID, Equal<AZConstants.BUYGROUP>>>))]
public virtual string UsrBuyingGroup { get; set; }
public abstract class usrBuyingGroup : PX.Data.BQL.BqlString.Field<usrBuyingGroup> { }
#endregion
Hi @larryly ,
In continuation @Naveen B statement on assign a default value, if your looking for dynamic attribute name to fetch the stored values, we can customize the sales order / inventory preference and create a custom field as buying group Attribute ID as a configuration and list all the attributes for user to select the attribute that they would like to use as buying group.
The modify the Sales order DAC to get the attribute ID from the preference screen .
#region UsrBuyingGroup
rPXDBString(50, IsUnicode = true)] ePXUIField(DisplayName = "Buying Group")] gPXDefault(typeof(Search2<CSAnswers.value, LeftJoin<BAccount, On<BAccount.noteID, Equal<CSAnswers.refNoteID>, And<BAccount.bAccountID, Equal<Current<SOOrder.customerID>>>>>, Where<CSAnswers.attributeID, Equal<SOSetup.UsrBuyinggroupID>>>))]
public virtual string UsrBuyingGroup { get; set; }
public abstract class usrBuyingGroup : PX.Data.BQL.BqlString.Field<usrBuyingGroup> { }
#endregion
Make sure on the Sales order graph preference screen DAC View is declared.
@Naveen B Thanks for you code. I was realize I can’t use default value for the field. Because the customer may changed. So I add a event to fill the field value.
@deebhane Thank you. It’s a great idea. I can use it on my other project.