Solved

getting an issue in my custom smart panel


Userlevel 3
Badge

Hi, 

I created a custom smart panel to add data into my grid in my customized form. In my smart panel, it loads data from  both POOrder and POline DAC’s. But the issue is when I select one item  based on the orderNbr and click add  button in my smart panel, all the values of same orderNbr get selected automatically and inserted into the grid.

I  have no idea about this. Can someone help me to solve this ?

thank you.

below code snippet for the reference which I have defined to select and assign them into the fields of the grid.

public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
{

if (POrdersView != null)
{
int lineNbr = Base.APProformaItems.Select().Count + 1;

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


if (order.Selected == false) continue;

{
APProformaItemList toBeInserted = new APProformaItemList();
toBeInserted.Ponbr = "aa";
toBeInserted.LineNbr = lineNbr++;
toBeInserted.POLineNbr = line.LineNbr;
toBeInserted.POrderQty = 30;
toBeInserted.Itemid = 25;
toBeInserted = Base.APProformaItems.Insert(toBeInserted);
Base.APProformaItems.Update(toBeInserted);

}
}

}
return adapter.Get();

 

icon

Best answer by Django 7 March 2023, 07:22

View original

15 replies

Userlevel 2

Hi there,

You can use Selected column from POLine DAC in your smart panel APSX code and in the graph instead of Selected column of POOrder DAC.

 

POLine line = result;

if (line.Selected == false) continue;

Userlevel 3
Badge

hi @EGolshtein67 ,

thank you for the response, I tested your suggestion but the issue is remained the same.

Userlevel 2

You can check APSX code of “Add PO Line” smart panel from Purchase Receipts (Screen ID PO302000) and use “AddPOOrderLine2” method of POReceiptEntry graph as example.

Userlevel 3
Badge

Hi there @EGolshtein67 ,

You have asked me to refer the business logic source of Purchase Receipts screen right? but I cannot see that there is “AddPOOrderLine2” method. How can I find it, Is there any other way to get into the POReceiptEntry graph code in the acumatica erp? It’s really appreciated if you can help me on this..

thank you. 

Userlevel 2

Hi there,

The source code of Acumatica is located in this folder <your website>\App_Data\CodeRepository.

POReceiptEntry.cs file is in this folder <your website>\App_Data\CodeRepository\PX.Objects.PO.

Userlevel 7
Badge +5

I’ve noticed that you’re working on the exact same project and have the exact same problem as the post below. Are you on the same team?  Should you just use one thread?

 

Userlevel 7
Badge +5

Correct me if I’m wrong but I feel like your question is more about the behaviour of the side panel than the code you’ve posted above.

Can you see if adding the line LineNbr field to the underlying query of the side panel helps (and perhaps OrderType and OrderNbr) from the POLine field?

 

Userlevel 3
Badge

hi @Django 

sorry , I didn’t get your point, you mean to try out any other filed instead of LineNbr from POLine?

 

Userlevel 7
Badge +5

In the screenshot, I only see PO Number.  But I think that you want to select individual rows from the PO, correct?

Userlevel 3
Badge

@Django 

yes you are right, for example I can select and add first order from 000003 PO number because it has only one there, but when I select and try to add one order from 000002, all the other orders from the same PO number get selected, that is the issue.

 

Userlevel 7
Badge +5

Right - so maybe look to see if the issue can be resolved if you add, to the GI, the key fields of POLine. And make sure that your join between POOrder and POLine are correct.

I don’t know if that will help but if the system is treating all of the lines of 000002 as the same value, then you need to figure out why your GI is behaving that way.

Userlevel 3
Badge

Hi @Django ,

In my smart panel, actually, I have used a grid to load data from POOrder and POline. Below i have added the full code and the screenshots of the form for your reference.

This is the from with ’ADD Purchase’ button
smart panel with loaded data from POrder and POLine a in a grid, as you can see when I select one order of PO number 00002, all the orders from the same PO number get selected.

The full code:

namespace GRIProformaInvoice.Extension
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APProformaEntry_Extension : PXGraphExtension<APProformaEntry>
{


public SelectFrom<POOrder>.InnerJoin<POLine>.
On<POLine.orderNbr.IsEqual<POOrder.orderNbr>>.View POrdersView; //view to get data from POOrder and POLine

public PXAction<APProforma> MyAction;

[PXUIField(DisplayName = "Add Purchase", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable myAction(PXAdapter adapter)
{

if (POrdersView.AskExt() == WebDialogResult.OK)
{

return InsertSelectedLines(adapter);

}
return adapter.Get();

}

public virtual IEnumerable InsertSelectedLines(PXAdapter adapter)
{

if (POrdersView != null)
{
int lineNbr = Base.APProformaItems.Select().Count + 1;

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


if (order.Selected == false) continue;

{
APProformaItemList toBeInserted = new APProformaItemList();
toBeInserted.Ponbr = “aa”;
toBeInserted.LineNbr = lineNbr++;
toBeInserted.POLineNbr = line.LineNbr;
toBeInserted.POrderQty = 30;
toBeInserted.Itemid = 25;
toBeInserted = Base.APProformaItems.Insert(toBeInserted);
Base.APProformaItems.Update(toBeInserted);

}
}

}
return adapter.Get();


}
}

in the previous ,message, You have mentioned that we need to add key fields of POLine to the GI, But I didn’t get it because we haven’t used a GI here, so could you please clearly mention where should that modification be placed?

thank you.

Userlevel 7
Badge +5

This is a guess but try flipping your view so that POLine is the primary table.

And your join between the two tables is incorrect. The primary key on POOrder is orderType and orderNbr and the primary key on POLine is orderType, orderNbr, lineNbr.

public SelectFrom<POLine>
.InnerJoin<POOrder>.On<POLine.orderNbr.IsEqual<POOrder.orderNbr>
.And<POLine.orderType.IsEqual<POOrder.orderType>>>
.View POrdersView

 

Userlevel 3
Badge

Hi @Django ,

thank you very much for the solution, now the issue is gone, I modified the view and the code as below and it worked. But now I got another one, when I gonna select and add another value from same  Order Nbr, nothing is happened. I’m not allowed to add another PO from the same Order Nbr, Have I done something wrong in the code? below is the reference for you.


namespace GRIProformaInvoice.Extension
{
// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class APProformaEntry_Extension : PXGraphExtension<APProformaEntry>
{



public SelectFrom<POLine>
.InnerJoin<POOrder>.On<POLine.orderNbr.IsEqual<POOrder.orderNbr>
.And<POLine.orderType.IsEqual<POOrder.orderType>>>
.View POrdersView;


public PXAction<APProforma> MyAction;
[PXUIField(DisplayName = "Add Purchase", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable myAction(PXAdapter adapter)
{


try
{
if (POrdersView.AskExt() == WebDialogResult.OK)
{
return InsertSelectedLines(adapter);
}
}

catch (PXDialogRequiredException ex)
{
PXTrace.WriteError(ex);
throw;
}


return adapter.Get();


}

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;



if (line.Selected == false) continue;



{
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.
toBeInserted.Amount = line.ExtCost;
toBeInserted = Base.APProformaItems.Insert(toBeInserted);
Base.APProformaItems.Update(toBeInserted);

}
}

}
return adapter.Get();

}



 

 

Userlevel 3
Badge

Hi @Django 

I solved the issue, I have commented toBeInserted.POLineNbr mistakenly, because I have an event handler to check whether there is the same POnbr and POlineNbr going to be added to avoid duplicates, that was the issue in the last updated code, thank you all again for giving the guidance with solutions.

Oshada.

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