Solved

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


Userlevel 3
Badge

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.

icon

Best answer by Naveen Boga 14 March 2023, 20:18

View original

22 replies

Userlevel 7
Badge +17

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

Userlevel 3
Badge

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. 

Userlevel 7
Badge +17

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

Userlevel 3
Badge

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.

Userlevel 7
Badge +17

@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

Userlevel 3
Badge

@Naveen Boga 

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

 

Userlevel 7
Badge +17

@oshadarodrigo64  did you debug and check the method InsertSelectedLines ?

Userlevel 3
Badge

@Naveen Boga  yes I checked.

Userlevel 7
Badge +17

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

Userlevel 3
Badge

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

 

Userlevel 7
Badge +17

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

 

Userlevel 3
Badge

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,

Userlevel 7
Badge +17

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

Userlevel 3
Badge

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?

Userlevel 7
Badge +17

@oshadarodrigo64  You can share it here

Userlevel 3
Badge

@Naveen Boga 

could you please check pm that I sent you?

Userlevel 7
Badge +17

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

 

 

Userlevel 3
Badge

@Naveen Boga , 

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

Userlevel 3
Badge

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 .

 

Userlevel 7
Badge +17

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

Your Custom DAC should have only the custom fields?

 

Userlevel 3
Badge

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.

Userlevel 7
Badge +17

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

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