Solved

Attribute ID Selector Determines Field Values in Custom Field

  • 27 July 2021
  • 1 reply
  • 499 views

Userlevel 3
Badge +1

I have created a line level field in AP303000 form and I need to have Attribute ID selector 

namespace MidayaCustomizations
{
public class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
{
#region UsrAttributeSelection
[PXDBString(250)]
[PXUIField(DisplayName = "Attribute ID")]
[PXSelector(typeof(Search<CSAttributeDetail.attributeID,Where<CSAttributeDetail.attributeID, Equal<CSAttribute.attributeID>>>),
typeof(CSAttributeDetail.attributeID))]
public virtual string UsrAttributeSelection { get; set; }
public abstract class usrAttributeSelection : PX.Data.BQL.BqlString.Field<usrAttributeSelection> { }
#endregion

#region UsrAttributeValues
[PXDBString(250)]
[PXUIField(DisplayName = "Attribute Values")]

public virtual string UsrAttributeValues { get; set; }
public abstract class usrAttributeValues : PX.Data.BQL.BqlString.Field<usrAttributeValues> { }
#endregion
}
}

And I need to get the Attribute ID from that field and in the UsrAttributeValues field, the values from that particular attribute should be populated (eg- Attribute ID “CSS” is a dropdown field and in UsrAttributeValues field these list of values should be available to be selected). 

protected void APTran_UsrAttributeSelection_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
APTran row = (APTran)e.Row;
if (row == null) return;
var rowExt = PXCache<APTran>.GetExtension<APTranExt>(row);

List<string> allowedValues = new List<string>();
List<string> allowedLabels = new List<string>();

if (rowExt != null)
{
foreach (CSAttributeDetail objCSAttributeDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<APTranExt.usrAttributeSelection>>>>.Select(Base, rowExt.UsrAttributeSelection))


{
allowedValues.Add(objCSAttributeDetail.ValueID);
allowedLabels.Add(objCSAttributeDetail.Description);
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(APTranExt.usrAttributeValues).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
}

}

Currently trying to use a field updated event, but I am facing errors, any help would be appreciated.

icon

Best answer by Naveen Boga 27 July 2021, 08:22

View original

1 reply

Userlevel 7
Badge +17

Hi @TharidhiP  “UsrAttributeSelection” selector will display the duplicate AttributeIDs from CSAttributeDetail table. If you want to load all the attribute id’s use the CSAttribute table instead of CSAttributeDetail.

 

For the dropdown control, we need to use the Fieldselecting event to load the attribute values. please use the below syntax

Ex: APTran_UsrAttributeSelection_FieldSelecting

 

Let me know if you have any doubts on this.

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