In Acumatica I can create a dropdown list field having constant number of values using this approach.
I put my custom attribute on a field.
#region FieldLocation
public abstract class fieldLocation : BqlString.Field<fieldLocation> { }
[PXDBString(5, IsUnicode = true)]
[PXUIField(DisplayName = "Field Location")]
[BZMagentoPaymentMethodFieldLocationTypes.BZList] //Dropdown
public string FieldLocation { get; set; }
#endregion
Custom attribute is something like this.
public class BZMagentoPaymentMethodFieldLocationTypes
{
public const string BillingAddress = "BA";
public const string Payment = "PYMT";
public const string ExtensionAttributes = "EXTAT";
public class UI
{
public const string BillingAddress = "BillingAddress";
public const string Payment = "Payment";
public const string ExtensionAttributes = "Extension Attributes";
}
public class BZListAttribute : PXStringListAttribute
{
public BZListAttribute() : base(new Tuple<string, string>[]
{
Pair(BillingAddress, UI.BillingAddress),
Pair(Payment, UI.Payment),
Pair(ExtensionAttributes, UI.ExtensionAttributes)
})
{ }
}
}
The result is this.
But I DO NOT want constant number of values in dropdown list. I want to take values, for example, from array or JSON. I want something called dynamic dropdown list.
After reading this Stackoverflow discussion I found some tips but I am far from the solution.
I have changed the attribute on field.
#region FieldLocation
public abstract class fieldLocation : BqlString.Field<fieldLocation> { }
[PXDBString(5, IsUnicode = true)]
[PXUIField(DisplayName = "Field Location")]
[ConfigurationKeyAttribute("Word", "Text")]
public string FieldLocation { get; set; }
#endregion
And I have corresponding custom attribute.
class ConfigurationKeyAttribute : PXStringListAttribute
{
private string _key;
private string _value;
public ConfigurationKeyAttribute(string key, string value) : base(new Tuple<string, string>[]
{
Pair(key, value)
})
{ }
}
My question is: What can I do to assign a value to an attribute? If I know how to assign a value, then I can assign value taken from JSON request.