Skip to main content
Solved

Need to use the unbound field for the UI in the smart panel


Forum|alt.badge.img

Hi, 

I need to add a custom unbound field to my smart panel. So I created a definition for an unbound field ‘selected’ in a DAC extension for POLine like below. This DAC extension is defined in my Graph extension which I use for my custom screen.

public sealed class PoSelected : PXCacheExtension<POLine>
{
            public static bool IsActive()
            {
                return true;
            }

            #region Selected

            [PXBool]
            //[PXDefault(false)]
            [PXUIField(DisplayName = "Selected")]

            public bool? Selected { get; set; }
            public abstract class selected : PX.Data.BQL.BqlBool.Field<selected>
            { }
            #endregion

}

(I’m not sure whether this definition is right or wrong, If there is something to be added please let me know also)

My purpose of using this field in the smart panel is allow the user to select rows and add to the custom screen like below.

For now I use the selected field which is already in the POLine dac, but using this I realized it causes errors with the data base, So I decided to define an unbound ‘selected’ in a dac extension, But I cannot use it for the UI as expected. below is the code that I tried to add this field to allow user to select rows one by one in the smart panel but it didn’t work, Should I do anything else in the code or in the customization project to add this field to the UI. So can someone help me to solve this issue?

for the reference :

POrdersView = view for getting data from POOrder and POLine

APProformaItemList = DAC for the grid which the selected data should be added in the custom screen

APProformaItems = view for the grid in the custom screen.

Best answer by Naveen Boga

@oshadarodrigo64 I just modified it a bit. Can you please check with this code and confirm

 

 public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
        {
            if (POrdersView != null)
            {

                int lineNbr = Base.APProformaItems.Select().Count + 1;

                foreach (PXResult<POLine, POOrder> result in POrdersView.Select())
                {
                    POOrder order = result;
                    POLine line = result;

                    PoSelected lineExt = line.GetExtension<PoSelected>(); 

                    if(line != null )

                    if (lineExt.Selected1 == true)

                    {
                        APProformaItemList toBeInserted = new APProformaItemList();
                        toBeInserted.Ponbr = order.OrderNbr;
                        toBeInserted.LineNbr = lineNbr++;
                        toBeInserted.POLineNbr = line.LineNbr;
                        toBeInserted.POrderQty = 30;
                        toBeInserted.Itemid = 25;
                        toBeInserted.Description = line?.TranDesc;
                        toBeInserted = Base.APProformaItems.Insert(toBeInserted);
                        Base.APProformaItems.Update(toBeInserted);


                    }
                }

            }
            return adapter.Get();
        }

 

View original
Did this topic help you find an answer to your question?

22 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 14, 2023

Hi @oshadarodrigo64  After selecting the checkbox and click on the ADD&CLOSE button, will those selected records are NOT adding to the main grid?


Forum|alt.badge.img

Hi @Naveen Boga ,

Thanks for the response, now the issue, after selecting the checkbox and clicked on the add button, all the selected and non-selected rows of the smart panel are added to the grid, that is why I said It doesn’t work as I expected. But before modify with this custom ‘selected’ field, I used POLine.selected for the smart panel and it worked properly when adding the values but I faced  an error when saving to the database, Here is the link for the community topic which I have already posted on that.

Because of didn’t get a proper solution, I tried to set an unbound field for the POLine, but it also doesn’t work properly. 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 14, 2023

@oshadarodrigo64 Thanks for providing the details.

After you click on the Add&Close, your code is adding all the line items to the grid, which means accordingly Selected value should be NULL OR TRUE.

Did you debug and verified? what is the value you are getting for the SELECTED unbound field?


Forum|alt.badge.img

Hi @Naveen Boga ,

I debugged and checked then PX.Data.PXDialogRequiredException is thrown. will this be the issue? actually I didn’t get what you asked for value for the unbound field. sorry to say that.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 14, 2023

@oshadarodrigo64 As you are using the “Smart Panel”, hence it will give a PXDialogRequried Exception but after you select the checkbox in the popup, then click on Add&Close button, then again it will invoke the code and there you need to check the SELECTED field value.

Here is a sample example for a smart panel

https://asiablog.acumatica.com/2015/11/using-smart-panel.html


Forum|alt.badge.img

@Naveen Boga 

after selecting and click on add$close button , it returns InsertSelectedLines(adapter) method,

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 14, 2023

@oshadarodrigo64  did you debug and check the method InsertSelectedLines ?


Forum|alt.badge.img

@Naveen Boga  yes I checked.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 14, 2023

@oshadarodrigo64  Okay, Can you please share the code for that method here?


Forum|alt.badge.img

@Naveen Boga 

sure, here I have applied a small change to ‘selected’ field as ‘selected1’ to test, 

public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
        {
            if (POrdersView != null)
            {

                int lineNbr = Base.APProformaItems.Select().Count + 1;

                foreach (PXResult< POLine, POOrder > result in POrdersView.Select())
                {
                    POOrder order = result;
                    POLine line = result;

                    PoSelected row = POrdersView.Current.GetExtension<PoSelected>();

                    if (row.Selected1 == false) continue;

                    if (row.Selected1 == true)

                    {
                        APProformaItemList toBeInserted = new APProformaItemList();
                        toBeInserted.Ponbr = order.OrderNbr;
                        toBeInserted.LineNbr = lineNbr++;
                        toBeInserted.POLineNbr = line.LineNbr;
                        toBeInserted.POrderQty = 30;
                        toBeInserted.Itemid = 25;
                        toBeInserted.Description = line?.TranDesc;
                        toBeInserted = Base.APProformaItems.Insert(toBeInserted);
                        Base.APProformaItems.Update(toBeInserted);


                    }
                }

            }
            return adapter.Get();

here also,

public sealed class PoSelected : PXCacheExtension<POLine>
        {
            public static bool IsActive()
            {
                return true;
            }


            #region Selected1

            [PXBool]
            //[PXDefault(false)]
            [PXUIField(DisplayName = "Selected Field")]

            //protected bool? _Selected = false;

            public bool? Selected1 { get; set; }
            public abstract class selected1 : PX.Data.BQL.BqlBool.Field<selected1> { }
            #endregion
        }

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • Answer
  • March 14, 2023

@oshadarodrigo64 I just modified it a bit. Can you please check with this code and confirm

 

 public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
        {
            if (POrdersView != null)
            {

                int lineNbr = Base.APProformaItems.Select().Count + 1;

                foreach (PXResult<POLine, POOrder> result in POrdersView.Select())
                {
                    POOrder order = result;
                    POLine line = result;

                    PoSelected lineExt = line.GetExtension<PoSelected>(); 

                    if(line != null )

                    if (lineExt.Selected1 == true)

                    {
                        APProformaItemList toBeInserted = new APProformaItemList();
                        toBeInserted.Ponbr = order.OrderNbr;
                        toBeInserted.LineNbr = lineNbr++;
                        toBeInserted.POLineNbr = line.LineNbr;
                        toBeInserted.POrderQty = 30;
                        toBeInserted.Itemid = 25;
                        toBeInserted.Description = line?.TranDesc;
                        toBeInserted = Base.APProformaItems.Insert(toBeInserted);
                        Base.APProformaItems.Update(toBeInserted);


                    }
                }

            }
            return adapter.Get();
        }

 


Forum|alt.badge.img

Hi @Naveen Boga 

Thanks for the response and sorry to being late to reply, I’ll check this and let you know whether it’s working or not,


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 15, 2023

Sure @oshadarodrigo64  if you are still facing any issues, just share me the package, I will check from my end and let you know.


Forum|alt.badge.img

Hi @Naveen Boga 

Now I can select and add rows one by one to the grid but unfortunately when saving to the data base again I’m getting the below error. 

 

so how can I share the package with you?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 15, 2023

@oshadarodrigo64  You can share it here


Forum|alt.badge.img

@Naveen Boga 

could you please check pm that I sent you?


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 15, 2023

@oshadarodrigo64  Thanks for sharing, but in the customization package there is NO code and DLL included. Hence I could not able to check from my side.

 

 


Forum|alt.badge.img

@Naveen Boga , 

oh sorry I didn’t realize that , let me check and upload it


Forum|alt.badge.img

Hi, 

small question, if I define a DAC extension for an existing table, should I add all the key fields of that existing table into my DAC extension? or no need of adding them? because for now I have defined the DAC extension with custom filed only .

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 15, 2023

No @oshadarodrigo64  Not required to add those key fields in the extension table.

Your Custom DAC should have only the custom fields?

 


Forum|alt.badge.img

Hi @Naveen Boga .

thank you for the response, but the issue of the ‘orderDate’ is still happening, I have shared the dll file with you also. I hope you will be able to go through it.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • March 16, 2023

@oshadarodrigo64  Thanks for sharing. I will check this and let you know


Reply


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