Hi I am trying to copy a defined attribute's combo box values from the Attributes screen (CS205000) to a custom field in the sales order header. This is my code but I don't get the combo box values populated in the field, it remains a normal text field. Could I please get some clarification on this or is it easier to directly using BQL in the DAC of the sales order custom field to achieve my requirement?
namespace PX.Objects.SO
{
public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
protected void SOOrder_UsrTypeOfOrder_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
List<string> allowedValues = new List<string>();
List<string> allowedLabels = new List<string>();
SOOrderEntry graph = (SOOrderEntry)sender.Graph;
var query = PXSelect<
CSAttributeDetail,
Where<
CSAttributeDetail.attributeID,
Equal<Required<CSAttributeDetail.attributeID>>
>
>.Select(graph, "TOO");
foreach (CSAttributeDetail attrDetail in query)
{
allowedValues.Add(attrDetail.ValueID);
allowedLabels.Add(attrDetail.Description);
}
e.ReturnState = PXStringState.CreateInstance(
e.ReturnState,
50,
true,
typeof(SOOrderExt.usrTypeOfOrder).Name,
false,
-1,
string.Empty,
allowedValues.ToArray(),
allowedLabels.ToArray(),
false,
null
);
}
}
}
Hi I figured out the solution the return character length must be set to 225 and no stringlist attribute is required in the field declaration.
protected void SOOrder_UsrTypeOfOrder_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
List<string> allowedValues = new List<string>();
List<string> allowedLabels = new List<string>();
foreach (CSAttributeDetail attrDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>>>>
.Select(Base, "TOO"))
{
allowedValues.Add(attrDetail.ValueID);
allowedLabels.Add(attrDetail.Description);
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 225, true, typeof(SOOrderExt.usrTypeOfOrder).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
}