Skip to main content

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.

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.


@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.


@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? 


@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.


@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


@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?


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?


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?


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


@Naveen Boga , I am wanting to do this same thing but to the existing “Stock Items” screen using the inventoryitem table. I added a couple of new fields but we regularly add to it so we would prefer to have it come from the attribute list like this so that multiple people can add to it instead of only one or two adding to it in the customization project. I dont have much experience with C# but i am pretty confident that I could change this code to point to the correct fields, but im not sure where i would put this. Would I put this into a DAC Extension for that screen to add this in?


Hi ​@justen0351  I just DMed you,


Reply