Solved

Get Attribute Values from Attributes form to Custom Line Level Field


Hi, I have a requirement where the values entered in the Attributes form need to be pulled into a custom form I make. So, I basically need a way to have a custom line level drop-down list field which contains all the values that are previously entered in the Attributes form. Any help regarding this would be appreciated.

icon

Best answer by Naveen B 12 July 2021, 19:35

@TharidhiP  Please find the below sample code to get the attribute values from Attributes screen.

 

 public virtual void DACName_FieleName_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{

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

foreach (CSAttributeDetail objCSAttributeDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>> >>.Select(Base, "PKGOPTIONS"));


{
allowedValues.Add(objCSAttributeDetail.Description);
}

e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(DACName.FieldName).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedValues.ToArray(), false, null);

}

 

View original

19 replies

Userlevel 6
Badge +8

Hi @TharidhiP  I’m bit confused, could you please provide some screenshot on your requirement. I will be helpful to me provide some inputs to you, if I can. 

Hi @Naveen B , I attached a screenshot of what is required. So whatever is declared in the attributes form can be reflected as values in my custom field.

Userlevel 6
Badge +8

@TharidhiP  You wanted to populate this attribute field values in your custom screen as a dropdown field?

@Naveen B  yes that is what’s needed.

Userlevel 6
Badge +8

@TharidhiP  Please find the below sample code to get the attribute values from Attributes screen.

 

 public virtual void DACName_FieleName_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{

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

foreach (CSAttributeDetail objCSAttributeDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>> >>.Select(Base, "PKGOPTIONS"));


{
allowedValues.Add(objCSAttributeDetail.Description);
}

e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(DACName.FieldName).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedValues.ToArray(), false, null);

}

 

Hi, @Naveen B is Basealready defined in the system? 

Userlevel 6
Badge +8

@TharidhiP  Understood, since it is new custom screen, please use “this” instead of “Base”.

public virtual void DACName_FieleName_FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{

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

foreach (CSAttributeDetail objCSAttributeDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>> >>.Select(this, "PKGOPTIONS"));


{
allowedValues.Add(objCSAttributeDetail.Description);
}

e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(DACName.FieldName).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedValues.ToArray(), false, null);

}

@Naveen B thank you so much, I will try this and see.

Userlevel 6
Badge +8

@TharidhiP  Sure, just let me know if you have any issue on this.

Hi @Naveen B, to show fields according to the packaging option selected in the dropdown list, I would have to use a RowSelected event handler, what is the best way to do this?

eg- Select Option 1 → one field appears in my tab item

      Select Option 2 → different field appears in my tab item

Userlevel 6
Badge +8

@TharidhiP  Below is my understanding, 

-- Based on the selection of “Packaging type” you need to enable the fields right? 

If this is your requirement, yes please have enable/disable logic in RowSelected Event

@Naveen B  yes, so I have to take the Value ID field in the Attributes form to make sure fields are hidden correctly according to packaging type?

Userlevel 6
Badge +8

Yes @TharidhiP you are correct

protected virtual void PKCFPackagingOption_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
PKCFPackagingOption row = e.Row as PKCFPackagingOption;
if (row == null) return;

if(row != null)
{
CSAttributeDetail attributeID = PXSelect<CSAttributeDetail, Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>>>>.Select(this, "PKGOPTIONS");
CSAttributeDetail valueID = PXSelect<CSAttributeDetail, Where<CSAttributeDetail.valueID, Equal<Required<CSAttributeDetail.valueID>>>>.Select(this, "Option01");

if(attributeID.Equals("PKGOPTIONS") && valueID.Equals("Option01"))
{
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBLength>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBWidth>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBHeight>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBNettWeight>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBGrossWeight>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBPerCarton>(cache, null, false);
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBStickerDetails>(cache, null, false);

}

}


}

Hi @Naveen B , I tried this code block out and does not seem to work, any suggestions?

Userlevel 6
Badge +8

Hi @TharidhiP  Below are my inputs and hope that helps.

  • It is NOT recommended to write a BQLs in RowSelected event ***. This code will slow down performance of that screen.
  • Also, you are retrieving all the records from CSAttributeDetail table instead of specific record
  • I’m assuming that Attribute value will be available in row extension and take the value from row and check (valueID == "Option01”) instead of writing the BQL queries and based on the you can have enable/disable logic in place.

Hi @Naveen B , I’m a bit confused on this topic, can you provide a sample code?

Userlevel 6
Badge +8

Sample Code..

  protected virtual void PKCFPackagingOption_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
PKCFPackagingOption row = e.Row as PKCFPackagingOption;
if (row == null) return;

if (row != null)
{
//CSAttributeDetail attributeID = PXSelect<CSAttributeDetail, Where<CSAttributeDetail.attributeID, Equal<Required<CSAttributeDetail.attributeID>>>>.Select(this, "PKGOPTIONS");
//CSAttributeDetail valueID = PXSelect<CSAttributeDetail, Where<CSAttributeDetail.valueID, Equal<Required<CSAttributeDetail.valueID>>>>.Select(this, "Option01");

PKCFPackagingOption rowExt = row.GetExtension<PKCFPackagingOption>();

if (rowExt.valueID == "Option01")
{
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBLength>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBWidth>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBHeight>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBNettWeight>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBGrossWeight>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBPerCarton>(cache, null, rowExt.valueID == "Option01");
PXUIFieldAttribute.SetVisible<PKCFPackagingOption.gBStickerDetails>(cache, null, rowExt.valueID == "Option01");

}
}
}

Hi, @Naveen B I get an error when using row extension

 

@Naveen B  Issue is resolved, thank you for your support.

Best Regards,

Tharidhi

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 — 2020  Acumatica, Inc. All rights reserved