Skip to main content
Solved

Get Attribute Values from Attributes form to Custom Line Level Field


Forum|alt.badge.img+2

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.

Best answer by Naveen Boga

@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
Did this topic help you find an answer to your question?

21 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 12, 2021

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. 


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 12, 2021

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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 12, 2021

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


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 12, 2021

@Naveen B  yes that is what’s needed.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • Answer
  • July 12, 2021

@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);

        }

 


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 13, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 13, 2021

@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);

        }


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 13, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 13, 2021

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


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 13, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 13, 2021

@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


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 13, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 13, 2021

Yes @TharidhiP you are correct


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 14, 2021
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?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 14, 2021

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.


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 14, 2021

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • July 14, 2021

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");

                }
            }
        }


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 14, 2021

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

 


Forum|alt.badge.img+2
  • Author
  • Pro I
  • 103 replies
  • July 14, 2021

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

Best Regards,

Tharidhi


Forum|alt.badge.img
  • Jr Varsity II
  • 14 replies
  • November 18, 2024

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


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3393 replies
  • November 18, 2024

Hi ​@justen0351  I just DMed you,


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings